glue for fetching epoch proofs from network
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ethcore::encoded;
|
||||
use ethcore::engines::{Engine, StateDependentProof};
|
||||
use ethcore::header::Header;
|
||||
use ethcore::receipt::Receipt;
|
||||
@@ -30,7 +31,7 @@ pub trait ChainDataFetcher: Send + Sync + 'static {
|
||||
type Error: ::std::fmt::Debug;
|
||||
|
||||
/// Future for fetching block body.
|
||||
type Body: IntoFuture<Item=Vec<u8>,Error=Self::Error>;
|
||||
type Body: IntoFuture<Item=encoded::Block,Error=Self::Error>;
|
||||
/// Future for fetching block receipts.
|
||||
type Receipts: IntoFuture<Item=Vec<Receipt>,Error=Self::Error>;
|
||||
/// Future for fetching epoch transition
|
||||
@@ -55,7 +56,7 @@ pub fn unavailable() -> Unavailable { Unavailable }
|
||||
impl ChainDataFetcher for Unavailable {
|
||||
type Error = &'static str;
|
||||
|
||||
type Body = Result<Vec<u8>, &'static str>;
|
||||
type Body = Result<encoded::Block, &'static str>;
|
||||
type Receipts = Result<Vec<Receipt>, &'static str>;
|
||||
type Transition = Result<Vec<u8>, &'static str>;
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ impl Default for Config {
|
||||
|
||||
/// Trait for interacting with the header chain abstractly.
|
||||
pub trait LightChainClient: Send + Sync {
|
||||
/// Adds a new `LightChainNotify` listener.
|
||||
fn add_listener(&self, listener: Weak<LightChainNotify>);
|
||||
|
||||
/// Get chain info.
|
||||
fn chain_info(&self) -> BlockChainInfo;
|
||||
|
||||
@@ -481,7 +484,7 @@ impl<T: ChainDataFetcher> Client<T> {
|
||||
};
|
||||
|
||||
if let Some(b) = b {
|
||||
block = Some(b.into_future().wait()?);
|
||||
block = Some(b.into_future().wait()?.into_inner());
|
||||
}
|
||||
|
||||
if let Some(r) = r {
|
||||
@@ -526,6 +529,10 @@ impl<T: ChainDataFetcher> Client<T> {
|
||||
}
|
||||
|
||||
impl<T: ChainDataFetcher> LightChainClient for Client<T> {
|
||||
fn add_listener(&self, listener: Weak<LightChainNotify>) {
|
||||
Client::add_listener(self, listener)
|
||||
}
|
||||
|
||||
fn chain_info(&self) -> BlockChainInfo { Client::chain_info(self) }
|
||||
|
||||
fn queue_header(&self, header: Header) -> Result<H256, BlockImportError> {
|
||||
|
||||
Reference in New Issue
Block a user