feat: add Default for NetworkArgs and DiscoveryArgs (#5658)

This commit is contained in:
Dan Cline
2023-12-01 17:07:53 -05:00
committed by GitHub
parent ba544d746c
commit a53e2c0666

View File

@@ -125,6 +125,26 @@ impl NetworkArgs {
}
}
impl Default for NetworkArgs {
fn default() -> Self {
Self {
discovery: DiscoveryArgs::default(),
trusted_peers: vec![],
trusted_only: false,
bootnodes: None,
peers_file: None,
identity: P2P_CLIENT_VERSION.to_string(),
p2p_secret_key: None,
no_persist_peers: false,
nat: NatResolver::Any,
addr: DEFAULT_DISCOVERY_ADDR,
port: DEFAULT_DISCOVERY_PORT,
max_outbound_peers: None,
max_inbound_peers: None,
}
}
}
/// Arguments to setup discovery
#[derive(Debug, Args)]
pub struct DiscoveryArgs {
@@ -166,6 +186,18 @@ impl DiscoveryArgs {
}
}
impl Default for DiscoveryArgs {
fn default() -> Self {
Self {
disable_discovery: false,
disable_dns_discovery: false,
disable_discv4_discovery: false,
addr: DEFAULT_DISCOVERY_ADDR,
port: DEFAULT_DISCOVERY_PORT,
}
}
}
#[cfg(test)]
mod tests {
use super::*;