mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 23:04:53 +00:00
Peer manager cfg (#2766)
## Issue Addressed I've done this change in a couple of WIPs already so I might as well submit it on its own. This changes no functionality but reduces coupling in a 0.0001%. It also helps new people who need to work in the peer manager to better understand what it actually needs from the outside ## Proposed Changes Add a config to the peer manager
This commit is contained in:
@@ -52,7 +52,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
Self {
|
||||
log: log.clone(),
|
||||
disconnected_peers: 0,
|
||||
banned_peers_count: BannedPeersCount::new(),
|
||||
banned_peers_count: BannedPeersCount::default(),
|
||||
peers,
|
||||
}
|
||||
}
|
||||
@@ -923,7 +923,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
"banned_peers > MAX_BANNED_PEERS despite no banned peers in db!"
|
||||
);
|
||||
// reset banned_peers this will also exit the loop
|
||||
self.banned_peers_count = BannedPeersCount::new();
|
||||
self.banned_peers_count = BannedPeersCount::default();
|
||||
None
|
||||
} {
|
||||
debug!(self.log, "Removing old banned peer"; "peer_id" => %to_drop);
|
||||
@@ -1087,6 +1087,7 @@ impl BanResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BannedPeersCount {
|
||||
/// The number of banned peers in the database.
|
||||
banned_peers: usize,
|
||||
@@ -1132,13 +1133,6 @@ impl BannedPeersCount {
|
||||
.get(ip)
|
||||
.map_or(false, |count| *count > BANNED_PEERS_PER_IP_THRESHOLD)
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
BannedPeersCount {
|
||||
banned_peers: 0,
|
||||
banned_peers_per_ip: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user