Update jsonrpc dependencies and rewrite dapps to futures. (#6522)
* Bump version. * Fix RPC crate. * Fix BoxFuture in crates. * Compiles and passes tests! * Get rid of .boxed() * Fixing issues with the UI. * Remove minihttp. Support threads. * Reimplement files serving to do it in chunks. * Increase chunk size. * Remove some unecessary copying. * Fix tests. * Fix stratum warning and ipfs todo. * Switch to proper branch of jsonrpc. * Update Cargo.lock. * Update docs. * Include dapps-glue in workspace. * fixed merge artifacts * Fix test compilation.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
492da38d67
commit
e8b418ca03
@@ -23,7 +23,8 @@ use ethcore::machine::EthereumMachine;
|
||||
use ethcore::receipt::Receipt;
|
||||
use ethsync::LightSync;
|
||||
|
||||
use futures::{future, Future, BoxFuture};
|
||||
use futures::{future, Future};
|
||||
use futures::future::Either;
|
||||
|
||||
use light::client::fetch::ChainDataFetcher;
|
||||
use light::on_demand::{request, OnDemand};
|
||||
@@ -33,6 +34,8 @@ use bigint::hash::H256;
|
||||
|
||||
const ALL_VALID_BACKREFS: &str = "no back-references, therefore all back-references valid; qed";
|
||||
|
||||
type BoxFuture<T, E> = Box<Future<Item = T, Error = E>>;
|
||||
|
||||
/// Allows on-demand fetch of data useful for the light client.
|
||||
pub struct EpochFetch {
|
||||
/// A handle to the sync service.
|
||||
@@ -45,7 +48,7 @@ impl EpochFetch {
|
||||
fn request<T>(&self, req: T) -> BoxFuture<T::Out, &'static str>
|
||||
where T: Send + request::RequestAdapter + 'static, T::Out: Send + 'static
|
||||
{
|
||||
match self.sync.read().upgrade() {
|
||||
Box::new(match self.sync.read().upgrade() {
|
||||
Some(sync) => {
|
||||
let on_demand = &self.on_demand;
|
||||
let maybe_future = sync.with_context(move |ctx| {
|
||||
@@ -53,12 +56,12 @@ impl EpochFetch {
|
||||
});
|
||||
|
||||
match maybe_future {
|
||||
Some(x) => x.map_err(|_| "Request canceled").boxed(),
|
||||
None => future::err("Unable to access network.").boxed(),
|
||||
Some(x) => Either::A(x.map_err(|_| "Request canceled")),
|
||||
None => Either::B(future::err("Unable to access network.")),
|
||||
}
|
||||
}
|
||||
None => future::err("Unable to access network").boxed(),
|
||||
}
|
||||
None => Either::B(future::err("Unable to access network")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,11 @@ impl<T: LightChainClient + 'static> IoHandler<ClientIoMessage> for QueueCull<T>
|
||||
});
|
||||
|
||||
match maybe_fetching {
|
||||
Some(fut) => fut.boxed(),
|
||||
Some(fut) => future::Either::A(fut),
|
||||
None => {
|
||||
debug!(target: "cull", "Unable to acquire network context; qed");
|
||||
future::ok(()).boxed()
|
||||
}
|
||||
future::Either::B(future::ok(()))
|
||||
},
|
||||
}
|
||||
}, Duration::from_millis(PURGE_TIMEOUT_MS), || {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user