Skip to content

Commit

Permalink
fix: ban trusted peer for a short period (#7071)
Browse files Browse the repository at this point in the history
  • Loading branch information
int88 committed Mar 11, 2024
1 parent 82b6504 commit ef1a196
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/net/network/src/peers/manager.rs
Expand Up @@ -298,7 +298,15 @@ impl PeersManager {

/// Bans the peer temporarily with the configured ban timeout
fn ban_peer(&mut self, peer_id: PeerId) {
self.ban_list.ban_peer_until(peer_id, std::time::Instant::now() + self.ban_duration);
let mut ban_duration = self.ban_duration;
if let Some(peer) = self.peers.get(&peer_id) {
if peer.is_trusted() {
// For misbehaving trusted peers, we provide a bit more leeway when penalizing them.
ban_duration = self.backoff_durations.medium;
}
}

self.ban_list.ban_peer_until(peer_id, std::time::Instant::now() + ban_duration);
self.queued_actions.push_back(PeerAction::BanPeer { peer_id });
}

Expand Down

0 comments on commit ef1a196

Please sign in to comment.