glue for fetching epoch proofs from network

This commit is contained in:
Robert Habermeier
2017-08-24 15:17:48 +02:00
parent 871a9c063e
commit b953f9b66a
15 changed files with 168 additions and 38 deletions

View File

@@ -25,7 +25,7 @@ use jsonrpc_core::Error;
use jsonrpc_macros::Trailing;
use light::cache::Cache as LightDataCache;
use light::client::{Client as LightClient, LightChainClient};
use light::client::LightChainClient;
use light::{cht, TransactionQueue};
use light::on_demand::{request, OnDemand};
@@ -62,9 +62,9 @@ use util::Address;
const NO_INVALID_BACK_REFS: &'static str = "Fails only on invalid back-references; back-references here known to be valid; qed";
/// Light client `ETH` (and filter) RPC.
pub struct EthClient {
pub struct EthClient<T> {
sync: Arc<LightSync>,
client: Arc<LightClient>,
client: Arc<T>,
on_demand: Arc<OnDemand>,
transaction_queue: Arc<RwLock<TransactionQueue>>,
accounts: Arc<AccountProvider>,
@@ -72,7 +72,7 @@ pub struct EthClient {
polls: Mutex<PollManager<PollFilter>>,
}
impl Clone for EthClient {
impl<T> Clone for EthClient<T> {
fn clone(&self) -> Self {
// each instance should have its own poll manager.
EthClient {
@@ -88,12 +88,12 @@ impl Clone for EthClient {
}
impl EthClient {
impl<T: LightChainClient + 'static> EthClient<T> {
/// Create a new `EthClient` with a handle to the light sync instance, client,
/// and on-demand request service, which is assumed to be attached as a handler.
pub fn new(
sync: Arc<LightSync>,
client: Arc<LightClient>,
client: Arc<T>,
on_demand: Arc<OnDemand>,
transaction_queue: Arc<RwLock<TransactionQueue>>,
accounts: Arc<AccountProvider>,
@@ -208,7 +208,7 @@ impl EthClient {
}
}
impl Eth for EthClient {
impl<T: LightChainClient + 'static> Eth for EthClient<T> {
type Metadata = Metadata;
fn protocol_version(&self) -> Result<String, Error> {
@@ -465,7 +465,7 @@ impl Eth for EthClient {
}
// This trait implementation triggers a blanked impl of `EthFilter`.
impl Filterable for EthClient {
impl<T: LightChainClient + 'static> Filterable for EthClient<T> {
fn best_block_number(&self) -> u64 { self.client.chain_info().best_block_number }
fn block_hash(&self, id: BlockId) -> Option<RpcH256> {