mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 13:15:41 +00:00
node: spawn block authoring and grandpa voter as blocking tasks (#6446)
* service: add spawner for essential tasks * node: spawn block authoring and grandpa voter as blocking tasks * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -82,7 +82,7 @@ pub use sc_network::config::{
|
||||
TransactionImportFuture,
|
||||
};
|
||||
pub use sc_tracing::TracingReceiver;
|
||||
pub use task_manager::SpawnTaskHandle;
|
||||
pub use task_manager::{SpawnEssentialTaskHandle, SpawnTaskHandle};
|
||||
use task_manager::TaskManager;
|
||||
use sp_blockchain::{HeaderBackend, HeaderMetadata};
|
||||
use sp_api::{ApiExt, ConstructRuntimeApi, ApiErrorExt};
|
||||
@@ -166,13 +166,19 @@ pub trait AbstractService: Future<Output = Result<(), Error>> + Send + Unpin + S
|
||||
/// The task name is a `&'static str` as opposed to a `String`. The reason for that is that
|
||||
/// in order to avoid memory consumption issues with the Prometheus metrics, the set of
|
||||
/// possible task names has to be bounded.
|
||||
#[deprecated(note = "Use `spawn_task_handle().spawn() instead.")]
|
||||
fn spawn_task(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static);
|
||||
|
||||
/// Spawns a task in the background that runs the future passed as
|
||||
/// parameter. The given task is considered essential, i.e. if it errors we
|
||||
/// trigger a service exit.
|
||||
#[deprecated(note = "Use `spawn_essential_task_handle().spawn() instead.")]
|
||||
fn spawn_essential_task(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static);
|
||||
|
||||
/// Returns a handle for spawning essential tasks. Any task spawned through this handle is
|
||||
/// considered essential, i.e. if it errors we trigger a service exit.
|
||||
fn spawn_essential_task_handle(&self) -> SpawnEssentialTaskHandle;
|
||||
|
||||
/// Returns a handle for spawning tasks.
|
||||
fn spawn_task_handle(&self) -> SpawnTaskHandle;
|
||||
|
||||
@@ -269,13 +275,20 @@ where
|
||||
let _ = essential_failed.send(());
|
||||
});
|
||||
|
||||
let _ = self.spawn_task(name, essential_task);
|
||||
let _ = self.spawn_task_handle().spawn(name, essential_task);
|
||||
}
|
||||
|
||||
fn spawn_task_handle(&self) -> SpawnTaskHandle {
|
||||
self.task_manager.spawn_handle()
|
||||
}
|
||||
|
||||
fn spawn_essential_task_handle(&self) -> SpawnEssentialTaskHandle {
|
||||
SpawnEssentialTaskHandle::new(
|
||||
self.essential_failed_tx.clone(),
|
||||
self.task_manager.spawn_handle(),
|
||||
)
|
||||
}
|
||||
|
||||
fn rpc_query(&self, mem: &RpcSession, request: &str) -> Pin<Box<dyn Future<Output = Option<String>> + Send>> {
|
||||
Box::pin(
|
||||
self.rpc_handlers.handle_request(request, mem.metadata.clone())
|
||||
|
||||
Reference in New Issue
Block a user