mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +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:
43
beacon_node/lighthouse_network/src/peer_manager/config.rs
Normal file
43
beacon_node/lighthouse_network/src/peer_manager/config.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
/// The time in seconds between re-status's peers.
|
||||
pub const DEFAULT_STATUS_INTERVAL: u64 = 300;
|
||||
|
||||
/// Default ping interval for outbound connections, in seconds.
|
||||
pub const DEFAULT_PING_INTERVAL_OUTBOUND: u64 = 15;
|
||||
|
||||
/// Default interval for inbound connections.
|
||||
pub const DEFAULT_PING_INTERVAL_INBOUND: u64 = 20;
|
||||
|
||||
/// Default number of peers to connect to.
|
||||
pub const DEFAULT_TARGET_PEERS: usize = 50;
|
||||
|
||||
/// Configurations for the PeerManager.
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
/* Peer count related configurations */
|
||||
/// Whether discovery is enabled.
|
||||
pub discovery_enabled: bool,
|
||||
/// Target number of peers to connect to.
|
||||
pub target_peer_count: usize,
|
||||
|
||||
/* RPC related configurations */
|
||||
/// Time in seconds between status requests sent to peers.
|
||||
pub status_interval: u64,
|
||||
/// The time in seconds between PING events. We do not send a ping if the other peer has PING'd
|
||||
/// us within this time frame (Seconds). This is asymmetric to avoid simultaneous pings. This
|
||||
/// interval applies to inbound connections: those in which we are not the dialer.
|
||||
pub ping_interval_inbound: u64,
|
||||
/// Interval between PING events for peers dialed by us.
|
||||
pub ping_interval_outbound: u64,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config {
|
||||
discovery_enabled: true,
|
||||
target_peer_count: DEFAULT_TARGET_PEERS,
|
||||
status_interval: DEFAULT_STATUS_INTERVAL,
|
||||
ping_interval_inbound: DEFAULT_PING_INTERVAL_INBOUND,
|
||||
ping_interval_outbound: DEFAULT_PING_INTERVAL_OUTBOUND,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user