net/settings: Use Settings::default() in SettingsOpt

This simplifies making default changes since now have to be done only once.
This commit is contained in:
parazyd
2023-11-24 11:18:47 +01:00
parent a61475b6a2
commit 7e0ffd41cd
2 changed files with 21 additions and 13 deletions

1
.gitignore vendored
View File

@@ -35,3 +35,4 @@
/vanityaddr
*.rusty-tags.emacs
/tags

View File

@@ -186,8 +186,7 @@ pub struct SettingsOpt {
impl From<SettingsOpt> for Settings {
fn from(opt: SettingsOpt) -> Self {
let version = option_env!("CARGO_PKG_VERSION").unwrap_or("0.0.0");
let app_version = semver::Version::parse(version).unwrap();
let def = Settings::default();
Self {
node_id: opt.node_id,
@@ -195,23 +194,31 @@ impl From<SettingsOpt> for Settings {
external_addrs: opt.external_addrs,
peers: opt.peers,
seeds: opt.seeds,
app_version,
app_version: def.app_version,
allowed_transports: opt.allowed_transports,
transport_mixing: opt.transport_mixing.unwrap_or(false),
outbound_connections: opt.outbound_connections.unwrap_or(0),
inbound_connections: opt.inbound_connections.unwrap_or(0),
manual_attempt_limit: opt.manual_attempt_limit.unwrap_or(0),
outbound_connect_timeout: opt.outbound_connect_timeout.unwrap_or(15),
channel_handshake_timeout: opt.channel_handshake_timeout.unwrap_or(10),
channel_heartbeat_interval: opt.channel_heartbeat_interval.unwrap_or(30),
transport_mixing: opt.transport_mixing.unwrap_or(def.transport_mixing),
outbound_connections: opt.outbound_connections.unwrap_or(def.outbound_connections),
inbound_connections: opt.inbound_connections.unwrap_or(def.inbound_connections),
manual_attempt_limit: opt.manual_attempt_limit.unwrap_or(def.manual_attempt_limit),
outbound_connect_timeout: opt
.outbound_connect_timeout
.unwrap_or(def.outbound_connect_timeout),
channel_handshake_timeout: opt
.channel_handshake_timeout
.unwrap_or(def.channel_handshake_timeout),
channel_heartbeat_interval: opt
.channel_heartbeat_interval
.unwrap_or(def.channel_heartbeat_interval),
localnet: opt.localnet,
hosts_quarantine_limit: opt.hosts_quarantine_limit.unwrap_or(15),
hosts_quarantine_limit: opt
.hosts_quarantine_limit
.unwrap_or(def.hosts_quarantine_limit),
outbound_peer_discovery_cooloff_time: opt
.outbound_peer_discovery_cooloff_time
.unwrap_or(30),
.unwrap_or(def.outbound_peer_discovery_cooloff_time),
outbound_peer_discovery_attempt_time: opt
.outbound_peer_discovery_attempt_time
.unwrap_or(5),
.unwrap_or(def.outbound_peer_discovery_attempt_time),
}
}
}