Update peerdb constants (#1444)
Increases the cache for disconnected and banned peers.
This commit is contained in:
parent
6c17b4696f
commit
1419501f2e
@ -10,9 +10,9 @@ use std::time::Instant;
|
|||||||
use types::{EthSpec, SubnetId};
|
use types::{EthSpec, SubnetId};
|
||||||
|
|
||||||
/// Max number of disconnected nodes to remember.
|
/// Max number of disconnected nodes to remember.
|
||||||
const MAX_DC_PEERS: usize = 100;
|
const MAX_DC_PEERS: usize = 500;
|
||||||
/// The maximum number of banned nodes to remember.
|
/// The maximum number of banned nodes to remember.
|
||||||
const MAX_BANNED_PEERS: usize = 300;
|
const MAX_BANNED_PEERS: usize = 1000;
|
||||||
|
|
||||||
/// Storage of known peers, their reputation and information
|
/// Storage of known peers, their reputation and information
|
||||||
pub struct PeerDB<TSpec: EthSpec> {
|
pub struct PeerDB<TSpec: EthSpec> {
|
||||||
@ -305,17 +305,15 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
|||||||
|
|
||||||
/// Sets the peer as disconnected. A banned peer remains banned
|
/// Sets the peer as disconnected. A banned peer remains banned
|
||||||
pub fn disconnect(&mut self, peer_id: &PeerId) {
|
pub fn disconnect(&mut self, peer_id: &PeerId) {
|
||||||
let log_ref = &self.log;
|
// Note that it could be the case we prevent new nodes from joining. In this instance,
|
||||||
let info = self.peers.entry(peer_id.clone()).or_insert_with(|| {
|
// we don't bother tracking the new node.
|
||||||
warn!(log_ref, "Disconnecting unknown peer";
|
if let Some(info) = self.peers.get_mut(peer_id) {
|
||||||
"peer_id" => peer_id.to_string());
|
if !info.connection_status.is_disconnected() && !info.connection_status.is_banned() {
|
||||||
PeerInfo::default()
|
info.connection_status.disconnect();
|
||||||
});
|
self.disconnected_peers += 1;
|
||||||
if !info.connection_status.is_disconnected() && !info.connection_status.is_banned() {
|
}
|
||||||
info.connection_status.disconnect();
|
self.shrink_to_fit();
|
||||||
self.disconnected_peers += 1;
|
|
||||||
}
|
}
|
||||||
self.shrink_to_fit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marks a peer as banned.
|
/// Marks a peer as banned.
|
||||||
|
Loading…
Reference in New Issue
Block a user