From 8a3f52bdd87444c3bb0ff908ab505f11cd6f0783 Mon Sep 17 00:00:00 2001 From: Pierre Krieger <pierre.krieger1708@gmail.com> Date: Thu, 21 Feb 2019 10:02:27 +0100 Subject: [PATCH] Fix #1825 (#1828) * Fix #1825 * Add comment --- .../network-libp2p/src/custom_proto/behaviour.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/substrate/core/network-libp2p/src/custom_proto/behaviour.rs b/substrate/core/network-libp2p/src/custom_proto/behaviour.rs index ca8fc55d378..6a69587eeae 100644 --- a/substrate/core/network-libp2p/src/custom_proto/behaviour.rs +++ b/substrate/core/network-libp2p/src/custom_proto/behaviour.rs @@ -499,12 +499,19 @@ where fn inject_dial_failure(&mut self, peer_id: Option<&PeerId>, addr: &Multiaddr, error: &dyn error::Error) { if let Some(peer_id) = peer_id.as_ref() { debug!(target: "sub-libp2p", "Failed to reach peer {:?} through {} => {:?}", peer_id, addr, error); - if self.connected_peers.contains(peer_id) { - self.topology.set_unreachable(addr); - } + self.topology.set_unreachable(addr); // Trigger a `connect_to_nodes` round. self.next_connect_to_nodes = Delay::new(Instant::now()); + + } else { + // This code path is only reached if `peer_id` is None, which means that we dialed an + // address without knowing the `PeerId` to expect. We don't currently do that, except + // in one situation: for convenience, we accept bootstrap node addresses in the format + // `IP:PORT`. + // There is no reason this trigger a `connect_to_nodes` round in that situation. + debug!(target: "sub-libp2p", "Failed to reach {} => {:?}", addr, error); + self.topology.set_unreachable(addr); } } -- GitLab