fix(network): don't disconnect reserved peers (#9608)

The priority of && and || was borked.
This commit is contained in:
Andronik Ordian 2018-09-25 11:59:21 +02:00 committed by Marek Kotewicz
parent 5a1dc3eb8a
commit c4af7464e5

View File

@ -751,12 +751,15 @@ impl Host {
let max_ingress = max(max_peers - min_peers, min_peers / 2); let max_ingress = max(max_peers - min_peers, min_peers / 2);
if reserved_only || if reserved_only ||
(s.info.originated && egress_count > min_peers) || (s.info.originated && egress_count > min_peers) ||
(!s.info.originated && ingress_count > max_ingress) && !self.reserved_nodes.read().contains(&id) { (!s.info.originated && ingress_count > max_ingress) {
if !self.reserved_nodes.read().contains(&id) {
// only proceed if the connecting peer is reserved. // only proceed if the connecting peer is reserved.
trace!(target: "network", "Disconnecting non-reserved peer {:?}", id);
s.disconnect(io, DisconnectReason::TooManyPeers); s.disconnect(io, DisconnectReason::TooManyPeers);
kill = true; kill = true;
break; break;
} }
}
if !self.filter.as_ref().map_or(true, |f| f.connection_allowed(&self_id, &id, ConnectionDirection::Inbound)) { if !self.filter.as_ref().map_or(true, |f| f.connection_allowed(&self_id, &id, ConnectionDirection::Inbound)) {
trace!(target: "network", "Inbound connection not allowed for {:?}", id); trace!(target: "network", "Inbound connection not allowed for {:?}", id);