From bf45f82144bd8f960874280e89cc44df6c50c18b Mon Sep 17 00:00:00 2001 From: niklasad1 Date: Tue, 3 Apr 2018 18:00:16 +0200 Subject: [PATCH] Remove unused dependencies --- Cargo.lock | 4 +--- whisper/cli/Cargo.toml | 4 ---- whisper/cli/src/main.rs | 34 ++++++++++++++++------------------ 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9d7bf0e424..68574d707ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2237,7 +2237,7 @@ dependencies = [ "parity-version 1.11.0", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", - "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3500,7 +3500,6 @@ name = "whisper-cli" version = "0.1.0" dependencies = [ "docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-devtools 1.11.0", "ethcore-network 1.11.0", "ethcore-network-devp2p 1.11.0", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", @@ -3510,7 +3509,6 @@ dependencies = [ "parity-whisper 0.1.0", "serde 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/whisper/cli/Cargo.toml b/whisper/cli/Cargo.toml index d1141961a76..6e70842510a 100644 --- a/whisper/cli/Cargo.toml +++ b/whisper/cli/Cargo.toml @@ -15,10 +15,6 @@ jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "pa jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } -[dev-dependencies] -ethcore-devtools = { path = "../../devtools" } -serde_json = "1.0" - [[bin]] name = "whisper-cli" path = "src/main.rs" diff --git a/whisper/cli/src/main.rs b/whisper/cli/src/main.rs index 67a63a95951..b22411a432a 100644 --- a/whisper/cli/src/main.rs +++ b/whisper/cli/src/main.rs @@ -1,4 +1,4 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// Copyright 2015-2018 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify @@ -30,20 +30,14 @@ extern crate jsonrpc_core; extern crate jsonrpc_pubsub; extern crate jsonrpc_http_server; -#[cfg(test)] -extern crate ethcore_devtools; - -#[cfg(test)] -extern crate serde_json; - #[macro_use] extern crate serde_derive; use docopt::Docopt; -use std::sync::Arc; -use std::{fmt, io, process, env}; +use std::{fmt, io, process, env, sync::Arc}; use jsonrpc_core::{Metadata, MetaIoHandler}; use jsonrpc_pubsub::{PubSubMetadata, Session}; +use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation}; const POOL_UNIT: usize = 1024 * 1024; const USAGE: &'static str = r#" @@ -56,7 +50,7 @@ Usage: Options: --whisper-pool-size SIZE Specify Whisper pool size [default: 10]. - -p, --port PORT Specify which port to use [default: 8545]. + -p, --port PORT Specify which RPC port to use [default: 8545]. -a, --address ADDRESS Specify which address to use [default: 127.0.0.1]. -h, --help Display this message and exit. @@ -116,7 +110,7 @@ struct RpcFactory { } impl RpcFactory { - pub fn make_handler(&self, net: Arc) -> whisper::rpc::WhisperClient { + fn make_handler(&self, net: Arc) -> whisper::rpc::WhisperClient { let whisper_pool_handle = WhisperPoolHandle { handle: self.handle.clone(), net: net }; whisper::rpc::WhisperClient::new(whisper_pool_handle, self.manager.clone()) } @@ -164,11 +158,11 @@ impl From for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { - Error::SockAddr(ref e) => write!(f, "{}", e), - Error::Docopt(ref e) => write!(f, "{}", e), - Error::Io(ref e) => write!(f, "{}", e), - Error::JsonRpc(ref e) => write!(f, "{:?}", e), - Error::Network(ref e) => write!(f, "{:?}", e), + Error::SockAddr(ref e) => write!(f, "SockAddrError: {}", e), + Error::Docopt(ref e) => write!(f, "DocoptError: {}", e), + Error::Io(ref e) => write!(f, "IoError: {}", e), + Error::JsonRpc(ref e) => write!(f, "JsonRpcError: {:?}", e), + Error::Network(ref e) => write!(f, "NetworkError: {}", e), } } } @@ -177,7 +171,10 @@ fn main() { panic_hook::set(); match execute(env::args()) { - Ok(_) => println!("ok"), + Ok(_) => { + println!("whisper-cli terminated"); + process::exit(1); + } Err(err) => { println!("{}", err); process::exit(1); @@ -223,10 +220,11 @@ fn execute(command: I) -> Result<(), Error> where I: IntoIterator, io.extend_with(whisper::rpc::WhisperPubSub::to_delegate(whisper_factory.make_handler(shared_network.clone()))); let server = jsonrpc_http_server::ServerBuilder::new(io) + .cors(DomainsValidation::AllowOnly(vec![AccessControlAllowOrigin::Null])) .start_http(&url.parse()?)?; server.wait(); - // This will never return + // This will never return if the http server runs without errors Ok(()) }