Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
fix(network): don't disconnect reserved peers
Browse files Browse the repository at this point in the history
The priority of && and || was borked.
  • Loading branch information
ordian committed Sep 20, 2018
1 parent 403c07c commit 5450c6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions util/network-devp2p/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,13 @@ impl Host {
// Outgoing connections are allowed as long as their count is <= min_peers
// Incoming connections are allowed to take all of the max_peers reserve, or at most half of the slots.
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 && ingress_count > max_ingress) && !self.reserved_nodes.read().contains(&id) {
(!s.info.originated && ingress_count > max_ingress)) &&
!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;
Expand Down

0 comments on commit 5450c6f

Please sign in to comment.