Ver código fonte

src/net: add explicit Default implementation for Settings and remove StructOptToml

ghassmo 4 anos atrás
pai
commit
f661c1e714
2 arquivos alterados com 18 adições e 3 exclusões
  1. 0 1
      Cargo.toml
  2. 18 2
      src/net/settings.rs

+ 0 - 1
Cargo.toml

@@ -211,7 +211,6 @@ net = [
 	"regex",
 	"rustls-pemfile",
 	"structopt",
-	"structopt-toml",
 
 	"util",
 	"system",

+ 18 - 2
src/net/settings.rs

@@ -2,13 +2,12 @@ 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, Debug, Deserialize, StructOpt, StructOptToml)]
+#[derive(Clone, Debug, Deserialize, StructOpt)]
 #[structopt()]
 pub struct Settings {
     #[structopt(short, long)]
@@ -32,3 +31,20 @@ pub struct Settings {
     #[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(),
+        }
+    }
+}