Switch offchain workers to new futures (#3285)

* Switch offchain workers to new futures

* Fix tests
This commit is contained in:
Pierre Krieger
2019-08-08 09:35:12 +02:00
committed by Gavin Wood
parent b29277239a
commit 3d65753d48
5 changed files with 13 additions and 16 deletions
+4 -2
View File
@@ -36,7 +36,7 @@ use crate::config::Configuration;
use primitives::{Blake2Hasher, H256, traits::BareCryptoStorePtr};
use rpc::{self, apis::system::SystemInfo};
use futures::{prelude::*, future::Executor};
use futures03::channel::mpsc;
use futures03::{FutureExt as _, channel::mpsc, compat::Compat};
// Type aliases.
// These exist mainly to avoid typing `<F as Factory>::Foo` all over the code.
@@ -279,7 +279,9 @@ impl<C: Components> OffchainWorker<Self> for C where
pool: &Arc<TransactionPool<C::TransactionPoolApi>>,
network_state: &Arc<dyn NetworkStateInfo + Send + Sync>,
) -> error::Result<Box<dyn Future<Item = (), Error = ()> + Send>> {
Ok(Box::new(offchain.on_block_imported(number, pool, network_state.clone())))
let future = offchain.on_block_imported(number, pool, network_state.clone())
.map(|()| Ok(()));
Ok(Box::new(Compat::new(future)))
}
}