zebra/zebra-network/src/config.rs

45 lines
1.6 KiB
Rust
Raw Normal View History

2019-10-16 15:16:29 -07:00
use std::{net::SocketAddr, time::Duration};
use crate::network::Network;
/// Configuration for networking code.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
2019-10-16 18:29:45 -07:00
/// The address on which this node should listen for connections.
pub listen_addr: SocketAddr,
2019-10-16 15:16:29 -07:00
/// The network to connect to.
pub network: Network,
/// The user-agent to advertise.
pub user_agent: String,
2019-10-16 15:16:29 -07:00
/// A list of initial peers for the peerset.
///
/// XXX this should be replaced with DNS names, not SocketAddrs
pub initial_peers: Vec<SocketAddr>,
/// The default RTT estimate for peer responses, used in load-balancing.
pub ewma_default_rtt: Duration,
/// The decay time for the exponentially-weighted moving average response time.
pub ewma_decay_time: Duration,
/// The outgoing request buffer size for the peer set.
pub peerset_request_buffer_size: usize,
2019-10-21 22:17:57 -07:00
/// The timeout for peer handshakes.
pub handshake_timeout: Duration,
}
impl Default for Config {
fn default() -> Config {
Config {
2019-10-16 18:29:45 -07:00
listen_addr: "127.0.0.1:28233"
.parse()
.expect("Hardcoded address should be parseable"),
user_agent: crate::constants::USER_AGENT.to_owned(),
2019-10-16 15:16:29 -07:00
network: Network::Mainnet,
initial_peers: Vec::new(),
ewma_default_rtt: Duration::from_secs(1),
ewma_decay_time: Duration::from_secs(60),
peerset_request_buffer_size: 1,
2019-10-21 22:17:57 -07:00
handshake_timeout: Duration::from_secs(4),
}
}
}