diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 6c48adb69..281b97589 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -15,8 +15,7 @@ // along with Parity. If not, see . use std::cmp::PartialEq; -use std::collections::BTreeMap; -use std::collections::HashSet; +use std::collections::{BTreeMap, HashSet, HashMap}; use std::str::FromStr; use std::sync::{Arc, Weak}; @@ -239,10 +238,10 @@ impl FullDependencies { use parity_rpc::v1::*; macro_rules! add_signing_methods { - ($namespace:ident, $handler:expr, $deps:expr) => { + ($namespace:ident, $handler:expr, $deps:expr, $nonces:expr) => { { let deps = &$deps; - let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool()); + let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool(), $nonces); if deps.signer_service.is_enabled() { $handler.extend_with($namespace::to_delegate(SigningQueueClient::new(&deps.signer_service, dispatcher, deps.remote.clone(), &deps.secret_store))) } else { @@ -252,10 +251,12 @@ impl FullDependencies { } } + let nonces = Arc::new(Mutex::new(HashMap::new())); let dispatcher = FullDispatcher::new( self.client.clone(), self.miner.clone(), self.fetch.pool(), + nonces.clone(), ); for api in apis { match *api { @@ -285,7 +286,7 @@ impl FullDependencies { let filter_client = EthFilterClient::new(self.client.clone(), self.miner.clone()); handler.extend_with(filter_client.to_delegate()); - add_signing_methods!(EthSigning, handler, self); + add_signing_methods!(EthSigning, handler, self, nonces.clone()); } }, Api::EthPubSub => { @@ -322,7 +323,7 @@ impl FullDependencies { ).to_delegate()); if !for_generic_pubsub { - add_signing_methods!(ParitySigning, handler, self); + add_signing_methods!(ParitySigning, handler, self, nonces.clone()); } }, Api::ParityPubSub => { @@ -440,6 +441,7 @@ impl LightDependencies { self.cache.clone(), self.transaction_queue.clone(), self.fetch.pool(), + Arc::new(Mutex::new(HashMap::new())), ); macro_rules! add_signing_methods { diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index 9220790e8..f17797619 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -95,9 +95,12 @@ pub struct FullDispatcher { impl FullDispatcher { /// Create a `FullDispatcher` from Arc references to a client and miner. - pub fn new(client: Arc, miner: Arc, pool: CpuPool) -> Self { - let nonces = Arc::new(Mutex::new(HashMap::new())); - + pub fn new( + client: Arc, + miner: Arc, + pool: CpuPool, + nonces: Arc>>, + ) -> Self { FullDispatcher { client, miner, @@ -278,9 +281,8 @@ impl LightDispatcher { cache: Arc>, transaction_queue: Arc>, pool: CpuPool, + nonces: Arc>>, ) -> Self { - let nonces = Arc::new(Mutex::new(HashMap::new())); - LightDispatcher { sync, client,