mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
src/net: implement structopt for net::Settings
net::Setting is able now to be inside top level Args struct directly
This commit is contained in:
@@ -1,38 +1,34 @@
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
|
||||
use serde::Deserialize;
|
||||
use structopt::StructOpt;
|
||||
use structopt_toml::StructOptToml;
|
||||
|
||||
/// Atomic pointer to network settings.
|
||||
pub type SettingsPtr = Arc<Settings>;
|
||||
|
||||
/// Defines the network settings.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)]
|
||||
#[structopt()]
|
||||
pub struct Settings {
|
||||
#[structopt(short, long)]
|
||||
pub inbound: Option<SocketAddr>,
|
||||
#[structopt(long, default_value = "0")]
|
||||
pub outbound_connections: u32,
|
||||
#[structopt(long, default_value = "0")]
|
||||
pub manual_attempt_limit: u32,
|
||||
|
||||
#[structopt(long, default_value = "8")]
|
||||
pub seed_query_timeout_seconds: u32,
|
||||
#[structopt(long, default_value = "10")]
|
||||
pub connect_timeout_seconds: u32,
|
||||
#[structopt(long, default_value = "4")]
|
||||
pub channel_handshake_seconds: u32,
|
||||
#[structopt(long, default_value = "10")]
|
||||
pub channel_heartbeat_seconds: u32,
|
||||
|
||||
#[structopt(short, long)]
|
||||
pub external_addr: Option<SocketAddr>,
|
||||
#[structopt(short, long)]
|
||||
pub peers: Vec<SocketAddr>,
|
||||
#[structopt(short, long)]
|
||||
pub seeds: Vec<SocketAddr>,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
inbound: None,
|
||||
outbound_connections: 0,
|
||||
manual_attempt_limit: 0,
|
||||
seed_query_timeout_seconds: 8,
|
||||
connect_timeout_seconds: 10,
|
||||
channel_handshake_seconds: 4,
|
||||
channel_heartbeat_seconds: 10,
|
||||
external_addr: None,
|
||||
peers: Vec::new(),
|
||||
seeds: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user