Skip to content

Commit

Permalink
Don't connect to reserved nodes if they're banned (paritytech#9020)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka authored Jun 11, 2021
1 parent 8f99b4b commit 218bd4f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/peerset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ impl Peerset {
set_id: SetId(set_index),
peer_id: peer.into_peer_id(),
});

self.alloc_slots(SetId(set_index));
}
}
}
Expand Down Expand Up @@ -524,6 +526,14 @@ impl Peerset {
peersstate::Peer::Connected(_) => continue,
};

// Don't connect to nodes with an abysmal reputation, even if they're reserved.
// This is a rather opinionated behaviour, and it wouldn't be fundamentally wrong to
// remove that check. If necessary, the peerset should be refactored to give more
// control over what happens in that situation.
if entry.reputation() < BANNED_THRESHOLD {
break;
}

match entry.try_outgoing() {
Ok(conn) => self.message_queue.push_back(Message::Connect {
set_id,
Expand Down

0 comments on commit 218bd4f

Please sign in to comment.