Wire-in Updater to parity RPC

This commit is contained in:
Gav Wood 2016-12-11 23:15:52 +01:00
parent d8ad09b654
commit d81d9d77b2
No known key found for this signature in database
GPG Key ID: C49C1ACA1CC9B252
5 changed files with 15 additions and 4 deletions

1
Cargo.lock generated
View File

@ -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)",

View File

@ -225,6 +225,7 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
&deps.client,
&deps.miner,
&deps.sync,
&deps.updater,
&deps.net_service,
&deps.secret_store,
deps.logger.clone(),

View File

@ -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"

View File

@ -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;

View File

@ -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<C, M, S: ?Sized> where
pub struct ParityClient<C, M, S: ?Sized, U> where
C: MiningBlockChainClient,
M: MinerService,
S: SyncProvider,
U: UpdateService,
{
client: Weak<C>,
miner: Weak<M>,
sync: Weak<S>,
updater: Weak<U>,
net: Weak<ManageNetwork>,
accounts: Weak<AccountProvider>,
logger: Arc<RotatingLogger>,
@ -61,16 +64,18 @@ pub struct ParityClient<C, M, S: ?Sized> where
dapps_port: Option<u16>,
}
impl<C, M, S: ?Sized> ParityClient<C, M, S> where
impl<C, M, S: ?Sized, U> ParityClient<C, M, S, U> where
C: MiningBlockChainClient,
M: MinerService,
S: SyncProvider,
U: UpdateService,
{
/// Creates new `ParityClient`.
pub fn new(
client: &Arc<C>,
miner: &Arc<M>,
sync: &Arc<S>,
updater: &Arc<U>,
net: &Arc<ManageNetwork>,
store: &Arc<AccountProvider>,
logger: Arc<RotatingLogger>,
@ -83,6 +88,7 @@ impl<C, M, S: ?Sized> ParityClient<C, M, S> 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<C, M, S: ?Sized> ParityClient<C, M, S> where
}
}
impl<C, M, S: ?Sized> Parity for ParityClient<C, M, S> where
impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
M: MinerService + 'static,
C: MiningBlockChainClient + 'static,
S: SyncProvider + 'static {
S: SyncProvider + 'static,
U: UpdateService + 'static {
fn transactions_limit(&self) -> Result<usize, Error> {
try!(self.active());