extend sync status interface to sync provider

This commit is contained in:
Nikolay Volf
2016-03-10 20:32:17 +04:00
parent 8dd41bfe0c
commit 25a63611f8
4 changed files with 20 additions and 18 deletions

View File

@@ -17,7 +17,7 @@
//! Eth rpc implementation.
use std::collections::HashMap;
use std::sync::{Arc, Weak, Mutex, RwLock};
use ethsync::{SyncStatusProvider, SyncState};
use ethsync::{SyncProvider, SyncState};
use jsonrpc_core::*;
use util::numbers::*;
use util::sha3::*;
@@ -32,13 +32,13 @@ use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncIn
use v1::helpers::{PollFilter, PollManager};
/// Eth rpc implementation.
pub struct EthClient<C, S> where C: BlockChainClient, S: SyncStatusProvider {
pub struct EthClient<C, S> where C: BlockChainClient, S: SyncProvider {
client: Weak<C>,
sync: Weak<S>,
hashrates: RwLock<HashMap<H256, u64>>,
}
impl<C, S> EthClient<C, S> where C: BlockChainClient, S: SyncStatusProvider {
impl<C, S> EthClient<C, S> where C: BlockChainClient, S: SyncProvider {
/// Creates new EthClient.
pub fn new(client: &Arc<C>, sync: &Arc<S>) -> Self {
EthClient {
@@ -94,7 +94,7 @@ impl<C, S> EthClient<C, S> where C: BlockChainClient, S: SyncStatusProvider {
}
}
impl<C, S> Eth for EthClient<C, S> where C: BlockChainClient + 'static, S: SyncStatusProvider + 'static {
impl<C, S> Eth for EthClient<C, S> where C: BlockChainClient + 'static, S: SyncProvider + 'static {
fn protocol_version(&self, params: Params) -> Result<Value, Error> {
match params {
Params::None => to_value(&U256::from(take_weak!(self.sync).status().protocol_version)),

View File

@@ -17,15 +17,15 @@
//! Net rpc implementation.
use std::sync::{Arc, Weak};
use jsonrpc_core::*;
use ethsync::SyncStatusProvider;
use ethsync::SyncProvider;
use v1::traits::Net;
/// Net rpc implementation.
pub struct NetClient<S> where S: SyncStatusProvider {
pub struct NetClient<S> where S: SyncProvider {
sync: Weak<S>
}
impl<S> NetClient<S> where S: SyncStatusProvider {
impl<S> NetClient<S> where S: SyncProvider {
/// Creates new NetClient.
pub fn new(sync: &Arc<S>) -> Self {
NetClient {
@@ -34,7 +34,7 @@ impl<S> NetClient<S> where S: SyncStatusProvider {
}
}
impl<S> Net for NetClient<S> where S: SyncStatusProvider + 'static {
impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
fn version(&self, _: Params) -> Result<Value, Error> {
Ok(Value::U64(take_weak!(self.sync).status().protocol_version as u64))
}