Update the service to std futures (#4447)

* Switch service to futures03

* Fix tests

* Fix service test and cli

* Re-add Executor trait to SpawnTaskHandle

* Fix node-service

* Update babe

* Fix browser node

* Update aura

* Revert back to tokio-executor to fix runtime panic

* Add todo item

* Fix service tests again

* Timeout test futures

* Fix tests

* nits

* Fix service test

* Remove zstd patch

* Re-add futures01 to aura and babe tests as a dev-dep

* Change failing test to tee

* Fix node

* Upgrade tokio

* fix society

* Start switching grandpa to stable futures

* Revert "Start switching grandpa to stable futures"

This reverts commit 9c1976346237637effc07c13f7d0403daf5e71cf.

* Fix utils

* Revert substrate service test

* Revert gitlab

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Ashley
2020-01-14 15:43:45 +01:00
committed by GitHub
parent 972be34e38
commit 3219be2508
24 changed files with 246 additions and 312 deletions
+3 -4
View File
@@ -17,7 +17,7 @@
//! Console informant. Prints sync progress and block events. Runs on the calling thread.
use sc_client_api::BlockchainEvents;
use futures::{StreamExt, TryStreamExt, FutureExt, future, compat::Stream01CompatExt};
use futures::prelude::*;
use log::{info, warn, trace};
use sp_runtime::traits::Header;
use sc_service::AbstractService;
@@ -33,8 +33,7 @@ pub fn build(service: &impl AbstractService) -> impl futures::Future<Output = ()
let display_notifications = service
.network_status(Duration::from_millis(5000))
.compat()
.try_for_each(move |(net_status, _)| {
.for_each(move |(net_status, _)| {
let info = client.usage_info();
if let Some(ref usage) = info.usage {
trace!(target: "usage", "Usage statistics: {}", usage);
@@ -42,7 +41,7 @@ pub fn build(service: &impl AbstractService) -> impl futures::Future<Output = ()
trace!(target: "usage", "Usage statistics not displayed as backend does not provide it")
}
display.display(&info, net_status);
future::ok(())
future::ready(())
});
let client = service.client();
+4 -7
View File
@@ -61,7 +61,7 @@ pub use traits::GetSharedParams;
use app_dirs::{AppInfo, AppDataType};
use log::info;
use lazy_static::lazy_static;
use futures::{Future, compat::Future01CompatExt, executor::block_on};
use futures::{Future, executor::block_on};
use sc_telemetry::TelemetryEndpoints;
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
@@ -426,8 +426,7 @@ impl<'a> ParseAndPrepareExport<'a> {
});
let mut export_fut = builder(config)?
.export_blocks(file, from.into(), to, json)
.compat();
.export_blocks(file, from.into(), to, json);
let fut = futures::future::poll_fn(|cx| {
if exit_recv.try_recv().is_ok() {
return Poll::Ready(Ok(()));
@@ -485,8 +484,7 @@ impl<'a> ParseAndPrepareImport<'a> {
});
let mut import_fut = builder(config)?
.import_blocks(file, false)
.compat();
.import_blocks(file, false);
let fut = futures::future::poll_fn(|cx| {
if exit_recv.try_recv().is_ok() {
return Poll::Ready(Ok(()));
@@ -537,8 +535,7 @@ impl<'a> CheckBlock<'a> {
let start = std::time::Instant::now();
let check = builder(config)?
.check_block(block_id)
.compat();
.check_block(block_id);
let mut runtime = tokio::runtime::Runtime::new().unwrap();
runtime.block_on(check)?;
println!("Completed in {} ms.", start.elapsed().as_millis());