From d81d9d77b2a4e93c2e33188ba5490c39945f81b5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 11 Dec 2016 23:15:52 +0100 Subject: [PATCH] Wire-in Updater to parity RPC --- Cargo.lock | 1 + parity/rpc_apis.rs | 1 + rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 + rpc/src/v1/impls/parity.rs | 15 +++++++++++---- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f109ae3c4..17ee175d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -521,6 +521,7 @@ dependencies = [ "jsonrpc-http-server 6.1.1 (git+https://github.com/ethcore/jsonrpc.git)", "jsonrpc-ipc-server 0.2.4 (git+https://github.com/ethcore/jsonrpc.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-updater 1.5.0", "rlp 0.1.0", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index ffd50b762..b52e5affc 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -225,6 +225,7 @@ pub fn setup_rpc(server: T, deps: Arc, apis: ApiSet &deps.client, &deps.miner, &deps.sync, + &deps.updater, &deps.net_service, &deps.secret_store, deps.logger.clone(), diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 5d974e59f..81da64f4d 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -25,6 +25,7 @@ ethash = { path = "../ethash" } ethsync = { path = "../sync" } ethjson = { path = "../json" } ethcore-devtools = { path = "../devtools" } +parity-updater = { path = "../updater" } rlp = { path = "../util/rlp" } fetch = { path = "../util/fetch" } rustc-serialize = "0.3" diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index bbd4a5164..18a0a535d 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -37,6 +37,7 @@ extern crate ethcore_ipc; extern crate time; extern crate rlp; extern crate fetch; +extern crate parity_updater as updater; #[macro_use] extern crate log; diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 1f995749a..af44f6cb8 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -30,6 +30,7 @@ use ethcore::miner::MinerService; use ethcore::client::{MiningBlockChainClient}; use ethcore::mode::Mode; use ethcore::account_provider::AccountProvider; +use updater::{Service as UpdateService}; use jsonrpc_core::Error; use v1::traits::Parity; @@ -44,14 +45,16 @@ use v1::helpers::dispatch::DEFAULT_MAC; use v1::helpers::auto_args::Trailing; /// Parity implementation. -pub struct ParityClient where +pub struct ParityClient where C: MiningBlockChainClient, M: MinerService, S: SyncProvider, + U: UpdateService, { client: Weak, miner: Weak, sync: Weak, + updater: Weak, net: Weak, accounts: Weak, logger: Arc, @@ -61,16 +64,18 @@ pub struct ParityClient where dapps_port: Option, } -impl ParityClient where +impl ParityClient where C: MiningBlockChainClient, M: MinerService, S: SyncProvider, + U: UpdateService, { /// Creates new `ParityClient`. pub fn new( client: &Arc, miner: &Arc, sync: &Arc, + updater: &Arc, net: &Arc, store: &Arc, logger: Arc, @@ -83,6 +88,7 @@ impl ParityClient where client: Arc::downgrade(client), miner: Arc::downgrade(miner), sync: Arc::downgrade(sync), + updater: Arc::downgrade(updater), net: Arc::downgrade(net), accounts: Arc::downgrade(store), logger: logger, @@ -100,10 +106,11 @@ impl ParityClient where } } -impl Parity for ParityClient where +impl Parity for ParityClient where M: MinerService + 'static, C: MiningBlockChainClient + 'static, - S: SyncProvider + 'static { + S: SyncProvider + 'static, + U: UpdateService + 'static { fn transactions_limit(&self) -> Result { try!(self.active());