From 64d566ff523da2c913138bd4805567dc2682f83a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 22 Feb 2016 13:58:41 +0100 Subject: [PATCH 1/2] Manage final user-input errors. --- parity/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index f4b7880ab..07741ee2a 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -214,17 +214,17 @@ impl Configuration { let mut public_address = None; if let Some(ref a) = self.args.flag_address { - public_address = Some(SocketAddr::from_str(a.as_ref()).expect("Invalid listen/public address given with --address")); + public_address = Some(SocketAddr::from_str(a.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --address", a))); listen_address = public_address; } if listen_address.is_none() { - listen_address = Some(SocketAddr::from_str(self.args.flag_listen_address.as_ref()).expect("Invalid listen address given with --listen-address")); + listen_address = Some(SocketAddr::from_str(self.args.flag_listen_address.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --listen-address", self.args.flag_listen_address))); } if let Some(ref a) = self.args.flag_public_address { if public_address.is_some() { - panic!("Conflicting flags: --address and --public-address"); + die!("Conflicting flags provided: --address and --public-address"); } - public_address = Some(SocketAddr::from_str(a.as_ref()).expect("Invalid listen address given with --public-address")); + public_address = Some(SocketAddr::from_str(a.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --public-address", a))); } (listen_address, public_address) } @@ -236,7 +236,7 @@ impl Configuration { let (listen, public) = self.net_addresses(); ret.listen_address = listen; ret.public_address = public; - ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).expect("Invalid key string")); + ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).unwrap_or_else(|_| s.sha3())); ret.discovery_enabled = !self.args.flag_no_discovery; ret.ideal_peers = self.args.flag_peers; let mut net_path = PathBuf::from(&self.path()); @@ -279,6 +279,7 @@ impl Configuration { // Setup rpc if self.args.flag_jsonrpc { + SocketAddr::from_str(&self.args.flag_jsonrpc_url).unwrap_or_else(|_|die!("{}: Invalid JSONRPC listen address given with --jsonrpc-url. Should be of the form 'IP:port'.", self.args.flag_jsonrpc_url)); setup_rpc_server(service.client(), sync.clone(), &self.args.flag_jsonrpc_url); } From 72d071922341bec2e2ae7ca2c3dc01f3d327b4c2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 22 Feb 2016 18:11:53 +0100 Subject: [PATCH 2/2] Update docs. --- parity/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parity/main.rs b/parity/main.rs index 07741ee2a..328bfc0e2 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -74,7 +74,7 @@ Options: --peers NUM Try to manintain that many peers [default: 25]. --no-discovery Disable new peer discovery. --upnp Use UPnP to try to figure out the correct network settings. - --node-key KEY Specify node secret key as hex string. + --node-key KEY Specify node secret key, either as 64-character hex string or input to SHA3 operation. --cache-pref-size BYTES Specify the prefered size of the blockchain cache in bytes [default: 16384]. --cache-max-size BYTES Specify the maximum size of the blockchain cache in bytes [default: 262144].