From 06a3557e3e86d50c9f045618e5fd7c5e1e058f36 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 20 Jun 2016 12:17:06 +0200 Subject: [PATCH] reserved_only CLI flag --- parity/cli.rs | 2 ++ parity/configuration.rs | 1 + parity/main.rs | 4 ++-- rpc/src/v1/impls/ethcore_set.rs | 1 - util/src/network/host.rs | 10 +++++----- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/parity/cli.rs b/parity/cli.rs index 8c6f2d72d..8fa788108 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -70,6 +70,7 @@ Networking Options: --reserved-peers FILE Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers. + --reserved-only Connect only to reserved nodes. API and Console Options: --jsonrpc-off Disable the JSON-RPC API server. @@ -240,6 +241,7 @@ pub struct Args { pub flag_nat: String, pub flag_node_key: Option, pub flag_reserved_peers: Option, + pub flag_reserved_only: bool, pub flag_cache_pref_size: usize, pub flag_cache_max_size: usize, pub flag_queue_max_size: usize, diff --git a/parity/configuration.rs b/parity/configuration.rs index e2a8f94b6..f0c0a169c 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -200,6 +200,7 @@ impl Configuration { net_path.push("network"); ret.config_path = Some(net_path.to_str().unwrap().to_owned()); ret.reserved_nodes = self.init_reserved_nodes(); + ret.reserved_only = self.args.flag_reserved_only; ret } diff --git a/parity/main.rs b/parity/main.rs index d5e61a842..02d3ca271 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -308,7 +308,7 @@ fn execute_export(conf: Configuration) { udp_port: None, nat_enabled: false, discovery_enabled: false, - pin: true, + reserved_only: true, boot_nodes: Vec::new(), use_secret: None, ideal_peers: 0, @@ -380,7 +380,7 @@ fn execute_import(conf: Configuration) { udp_port: None, nat_enabled: false, discovery_enabled: false, - pin: true, + reserved_only: true, boot_nodes: Vec::new(), use_secret: None, ideal_peers: 0, diff --git a/rpc/src/v1/impls/ethcore_set.rs b/rpc/src/v1/impls/ethcore_set.rs index b07dcbf9e..cbd9c4309 100644 --- a/rpc/src/v1/impls/ethcore_set.rs +++ b/rpc/src/v1/impls/ethcore_set.rs @@ -74,5 +74,4 @@ impl EthcoreSet for EthcoreSetClient where M: MinerService + 'static { to_value(&true) }) } - } diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 25b1629f8..7e4b0c3a0 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -65,8 +65,8 @@ pub struct NetworkConfiguration { pub nat_enabled: bool, /// Enable discovery pub discovery_enabled: bool, - /// Pin to boot nodes only - pub pin: bool, + /// Pin to reserved nodes only + pub reserved_only: bool, /// List of initial node addresses pub boot_nodes: Vec, /// Use provided node key instead of default @@ -93,7 +93,7 @@ impl NetworkConfiguration { udp_port: None, nat_enabled: true, discovery_enabled: true, - pin: false, + reserved_only: false, boot_nodes: Vec::new(), use_secret: None, ideal_peers: 25, @@ -483,7 +483,7 @@ impl Host where Message: Send + Sync + Clone { // Initialize discovery. let discovery = { let info = self.info.read().unwrap(); - if info.config.discovery_enabled && !info.config.pin { + if info.config.discovery_enabled && !info.config.reserved_only { Some(Discovery::new(&info.keys, public_endpoint.address.clone(), public_endpoint, DISCOVERY)) } else { None } }; @@ -544,7 +544,7 @@ impl Host where Message: Send + Sync + Clone { return; } let ideal_peers = { self.info.read().unwrap().config.ideal_peers }; - let pin = { self.info.read().unwrap().config.pin }; + let pin = { self.info.read().unwrap().config.reserved_only }; let session_count = self.session_count(); if session_count >= ideal_peers as usize + self.pinned_nodes.len() { // check if all pinned nodes are connected.