From c4af7464e5d6cb8676f71b29fbd0fd118f754b11 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Tue, 25 Sep 2018 11:59:21 +0200 Subject: [PATCH] fix(network): don't disconnect reserved peers (#9608) The priority of && and || was borked. --- util/network-devp2p/src/host.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs index c43aab4bd..8df7a89a3 100644 --- a/util/network-devp2p/src/host.rs +++ b/util/network-devp2p/src/host.rs @@ -751,11 +751,14 @@ impl Host { let max_ingress = max(max_peers - min_peers, min_peers / 2); if reserved_only || (s.info.originated && egress_count > min_peers) || - (!s.info.originated && ingress_count > max_ingress) && !self.reserved_nodes.read().contains(&id) { - // only proceed if the connecting peer is reserved. - s.disconnect(io, DisconnectReason::TooManyPeers); - kill = true; - break; + (!s.info.originated && ingress_count > max_ingress) { + if !self.reserved_nodes.read().contains(&id) { + // only proceed if the connecting peer is reserved. + trace!(target: "network", "Disconnecting non-reserved peer {:?}", id); + s.disconnect(io, DisconnectReason::TooManyPeers); + kill = true; + break; + } } if !self.filter.as_ref().map_or(true, |f| f.connection_allowed(&self_id, &id, ConnectionDirection::Inbound)) {