From a910797f22a0a6c18f9be923002a9f652cdb1703 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 21 Sep 2018 09:32:23 +0200 Subject: [PATCH] Fix invalid state after peer id mismatch (#503) --- core/src/nodes/swarm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/nodes/swarm.rs b/core/src/nodes/swarm.rs index bf9f49cd..ab3cd1ab 100644 --- a/core/src/nodes/swarm.rs +++ b/core/src/nodes/swarm.rs @@ -511,6 +511,10 @@ where let num_remain = attempt.next_attempts.len(); let failed_addr = attempt.cur_attempted.clone(); + // Note: at the moment, a peer id mismatch can drop a legitimate connection, which is + // why we have to purge `connected_multiaddresses`. + // See https://github.com/libp2p/rust-libp2p/issues/502 + self.connected_multiaddresses.remove(&peer_id); self.active_nodes.peer_mut(&peer_id) .expect("When we receive a NodeReached or NodeReplaced event from active_nodes, \ it is guaranteed that the PeerId is valid and therefore that \