mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
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:
@@ -1,5 +1,5 @@
|
||||
use crate::service;
|
||||
use futures::{future::{select, Map}, FutureExt, TryFutureExt, channel::oneshot, compat::Future01CompatExt};
|
||||
use futures::{future::{select, Map, Either}, FutureExt, channel::oneshot};
|
||||
use std::cell::RefCell;
|
||||
use tokio::runtime::Runtime;
|
||||
pub use sc_cli::{VersionInfo, IntoExit, error};
|
||||
@@ -75,36 +75,23 @@ where
|
||||
|
||||
let informant = informant::build(&service);
|
||||
|
||||
let future = select(exit, informant)
|
||||
.map(|_| Ok(()))
|
||||
.compat();
|
||||
|
||||
runtime.executor().spawn(future);
|
||||
let handle = runtime.spawn(select(exit, informant));
|
||||
|
||||
// we eagerly drop the service so that the internal exit future is fired,
|
||||
// but we need to keep holding a reference to the global telemetry guard
|
||||
let _telemetry = service.telemetry();
|
||||
|
||||
let service_res = {
|
||||
let exit = e.into_exit();
|
||||
let service = service
|
||||
.map_err(|err| error::Error::Service(err))
|
||||
.compat();
|
||||
let select = select(service, exit)
|
||||
.map(|_| Ok(()))
|
||||
.compat();
|
||||
runtime.block_on(select)
|
||||
};
|
||||
let exit = e.into_exit();
|
||||
let service_res = runtime.block_on(select(service, exit));
|
||||
|
||||
let _ = exit_send.send(());
|
||||
|
||||
// TODO [andre]: timeout this future #1318
|
||||
runtime.block_on(handle);
|
||||
|
||||
use futures01::Future;
|
||||
|
||||
let _ = runtime.shutdown_on_idle().wait();
|
||||
|
||||
service_res
|
||||
match service_res {
|
||||
Either::Left((res, _)) => res.map_err(error::Error::Service),
|
||||
Either::Right((_, _)) => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// handles ctrl-c
|
||||
|
||||
@@ -12,6 +12,7 @@ pub use sc_executor::NativeExecutor;
|
||||
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use sc_basic_authority;
|
||||
use futures::{FutureExt, compat::Future01CompatExt};
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
@@ -163,7 +164,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
service.spawn_task_handle(),
|
||||
)?);
|
||||
)?.compat().map(drop));
|
||||
},
|
||||
(true, false) => {
|
||||
// start the full GRANDPA voter
|
||||
@@ -180,7 +181,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
// if it fails we take down the service with it.
|
||||
service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?);
|
||||
service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?.compat().map(drop));
|
||||
},
|
||||
(_, true) => {
|
||||
grandpa::setup_disabled_grandpa(
|
||||
|
||||
Reference in New Issue
Block a user