Remove TaskExecutor from the API of the informant (#2642)

* Remove TaskExecutor from the API of the informant

* Fix node-template
This commit is contained in:
Pierre Krieger
2019-05-23 10:44:36 +02:00
committed by Gavin Wood
parent 3860d7c810
commit 6431cdf601
3 changed files with 13 additions and 6 deletions
+9 -2
View File
@@ -32,9 +32,16 @@ use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{Header, SaturatedConversion};
/// Spawn informant on the event loop
#[deprecated(note = "Please use informant::build instead, and then create the task manually")]
pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExecutor) where
C: Components,
{
handle.spawn(exit.until(build(service)).map(|_| ()));
}
/// Creates an informant in the form of a `Future` that must be polled regularly.
pub fn build<C>(service: &Service<C>) -> impl Future<Item = (), Error = ()>
where C: Components {
let network = service.network();
let client = service.client();
let txpool = service.transaction_pool();
@@ -156,8 +163,8 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
Ok(())
});
let informant_work = display_notifications.join3(display_block_import, display_txpool_import);
handle.spawn(exit.until(informant_work).map(|_| ()));
display_notifications.join3(display_block_import, display_txpool_import)
.map(|((), (), ())| ())
}
fn speed(best_number: u64, last_number: Option<u64>, last_update: time::Instant) -> String {
+2 -2
View File
@@ -61,8 +61,8 @@ fn run_until_exit<T, C, E>(
{
let (exit_send, exit) = exit_future::signal();
let executor = runtime.executor();
informant::start(&service, exit.clone(), executor.clone());
let informant = informant::build(&service);
runtime.executor().spawn(exit.until(informant).map(|_| ()));
let _ = runtime.block_on(e.into_exit());
exit_send.fire();
+2 -2
View File
@@ -118,8 +118,8 @@ fn run_until_exit<T, C, E>(
{
let (exit_send, exit) = exit_future::signal();
let executor = runtime.executor();
cli::informant::start(&service, exit.clone(), executor.clone());
let informant = cli::informant::build(&service);
runtime.executor().spawn(exit.until(informant).map(|_| ()));
let _ = runtime.block_on(e.into_exit());
exit_send.fire();