From 2aabe801b0317285317a0ef07a723c54cda0e604 Mon Sep 17 00:00:00 2001 From: chevdor Date: Fri, 3 Aug 2018 17:18:31 +0200 Subject: [PATCH 1/2] Add new flag to allow listening to all interfaces Fix #439 Fix #494 --- substrate/cli/src/cli.yml | 8 ++++++++ substrate/cli/src/lib.rs | 7 +++++-- substrate/runtime/staking/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/substrate/cli/src/cli.yml b/substrate/cli/src/cli.yml index 9c156061add9b..d7ca7e89f28d1 100644 --- a/substrate/cli/src/cli.yml +++ b/substrate/cli/src/cli.yml @@ -46,6 +46,14 @@ args: value_name: PORT help: Specify p2p protocol TCP port takes_value: true + - rpc-external: + long: rpc-external + help: Listen to all rpc interfaces (Default is local) + takes_value: false + - ws-external: + long: ws-external + help: Listen to all web socket interfaces (Default is local) + takes_value: false - rpc-port: long: rpc-port value_name: PORT diff --git a/substrate/cli/src/lib.rs b/substrate/cli/src/lib.rs index d3512a415f1e9..b4dd7f8b37afb 100644 --- a/substrate/cli/src/lib.rs +++ b/substrate/cli/src/lib.rs @@ -295,8 +295,11 @@ where config.keys.push("Alice".into()); } - config.rpc_http = Some(parse_address("127.0.0.1:9933", "rpc-port", &matches)?); - config.rpc_ws = Some(parse_address("127.0.0.1:9944", "ws-port", &matches)?); + let rpc_interface: &str = if matches.is_present("rpc-external") { "0.0.0.0" } else { "127.0.0.1" }; + let ws_interface: &str = if matches.is_present("ws-external") { "0.0.0.0" } else { "127.0.0.1" }; + + config.rpc_http = Some(parse_address(&format!("{}:{}", rpc_interface, 9933), "rpc-port", &matches)?); + config.rpc_ws = Some(parse_address(&format!("{}:{}", ws_interface, 9944), "ws-port", &matches)?); // Override telemetry if matches.is_present("no-telemetry") { diff --git a/substrate/runtime/staking/src/lib.rs b/substrate/runtime/staking/src/lib.rs index b0436c5fa30ae..f7c03972d574f 100644 --- a/substrate/runtime/staking/src/lib.rs +++ b/substrate/runtime/staking/src/lib.rs @@ -438,7 +438,7 @@ impl Module { /// Returns if the account was successfully updated or update has led to killing of the account. pub fn set_free_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { // Commented out for no - but consider it instructive. -// assert!(!Self::voting_balance(who).is_zero()); + // assert!(!Self::voting_balance(who).is_zero()); if balance < Self::existential_deposit() { Self::on_free_too_low(who); UpdateBalanceOutcome::AccountKilled From f1fca90ceba07e2e0edcd5a2422b6f5d39f546db Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 8 Aug 2018 23:28:55 +0200 Subject: [PATCH 2/2] Fix capitalisation --- substrate/cli/src/cli.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/cli/src/cli.yml b/substrate/cli/src/cli.yml index d7ca7e89f28d1..ace575e6760e5 100644 --- a/substrate/cli/src/cli.yml +++ b/substrate/cli/src/cli.yml @@ -48,11 +48,11 @@ args: takes_value: true - rpc-external: long: rpc-external - help: Listen to all rpc interfaces (Default is local) + help: Listen to all RPC interfaces (default is local) takes_value: false - ws-external: long: ws-external - help: Listen to all web socket interfaces (Default is local) + help: Listen to all Websocket interfaces (default is local) takes_value: false - rpc-port: long: rpc-port