Use SpawnNamed to give tasks names (#1379)

This commit is contained in:
Bastian Köcher
2020-07-08 17:42:29 +02:00
committed by GitHub
parent fef3c181d9
commit 51a698803c
7 changed files with 139 additions and 117 deletions
+3 -2
View File
@@ -23,7 +23,7 @@
#![warn(missing_docs)]
use futures::prelude::*;
use futures::{channel::{mpsc, oneshot}, task::Spawn};
use futures::channel::{mpsc, oneshot};
use keystore::KeyStorePtr;
use polkadot_primitives::{
Hash, Block,
@@ -39,6 +39,7 @@ use client::{
};
use sp_api::{ApiExt, ProvideRuntimeApi};
use codec::{Encode, Decode};
use sp_core::traits::SpawnNamed;
use log::warn;
@@ -174,7 +175,7 @@ impl Store {
&self,
wrapped_block_import: I,
client: Arc<P>,
spawner: impl Spawn,
spawner: impl SpawnNamed,
keystore: KeyStorePtr,
) -> ClientResult<AvailabilityBlockImport<I, P>>
where
+5 -6
View File
@@ -20,7 +20,7 @@ use std::sync::Arc;
use std::thread;
use log::{error, info, trace, warn};
use sp_blockchain::{Result as ClientResult};
use sp_blockchain::Result as ClientResult;
use sp_runtime::traits::{Header as HeaderT, Block as BlockT, HashFor, BlakeTwo256};
use sp_api::{ApiExt, ProvideRuntimeApi};
use client::{
@@ -32,12 +32,13 @@ use consensus_common::{
ImportResult,
import_queue::CacheKeyId,
};
use sp_core::traits::SpawnNamed;
use polkadot_primitives::{Block, BlockId, Hash};
use polkadot_primitives::parachain::{
ParachainHost, ValidatorId, AbridgedCandidateReceipt, AvailableData,
ValidatorPair, ErasureChunk,
};
use futures::{prelude::*, future::select, channel::{mpsc, oneshot}, task::{Spawn, SpawnExt}};
use futures::{prelude::*, future::select, channel::{mpsc, oneshot}};
use futures::future::AbortHandle;
use keystore::KeyStorePtr;
@@ -641,7 +642,7 @@ impl<I, P> AvailabilityBlockImport<I, P> {
pub(crate) fn new(
client: Arc<P>,
block_import: I,
spawner: impl Spawn,
spawner: impl SpawnNamed,
keystore: KeyStorePtr,
to_worker: mpsc::UnboundedSender<WorkerMsg>,
) -> Self
@@ -662,9 +663,7 @@ impl<I, P> AvailabilityBlockImport<I, P> {
to_worker.clone(),
));
if let Err(_) = spawner.spawn(prune_available.map(drop)) {
error!(target: LOG_TARGET, "Failed to spawn availability pruning task");
}
spawner.spawn("polkadot-prune-availibility", prune_available.map(drop).boxed());
AvailabilityBlockImport {
client,