mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Move spawning tasks from thread pools to Service's TaskManager for block importing (#5647)
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ use std::{
|
||||
collections::HashMap
|
||||
};
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::{prelude::*, future::BoxFuture};
|
||||
use parking_lot::Mutex;
|
||||
use log::{debug, info, trace};
|
||||
|
||||
@@ -788,13 +788,14 @@ impl<Block: BlockT, C, I, P> BlockImport<Block> for AuraBlockImport<Block, C, I,
|
||||
}
|
||||
|
||||
/// Start an import queue for the Aura consensus algorithm.
|
||||
pub fn import_queue<B, I, C, P>(
|
||||
pub fn import_queue<B, I, C, P, F>(
|
||||
slot_duration: SlotDuration,
|
||||
block_import: I,
|
||||
justification_import: Option<BoxJustificationImport<B>>,
|
||||
finality_proof_import: Option<BoxFinalityProofImport<B>>,
|
||||
client: Arc<C>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: F,
|
||||
) -> Result<AuraImportQueue<B, sp_api::TransactionFor<C, B>>, sp_consensus::Error> where
|
||||
B: BlockT,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
|
||||
@@ -804,6 +805,7 @@ pub fn import_queue<B, I, C, P>(
|
||||
P: Pair + Send + Sync + 'static,
|
||||
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
|
||||
P::Signature: Encode + Decode,
|
||||
F: Fn(BoxFuture<'static, ()>) -> (),
|
||||
{
|
||||
register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?;
|
||||
initialize_authorities_cache(&*client)?;
|
||||
@@ -818,6 +820,7 @@ pub fn import_queue<B, I, C, P>(
|
||||
Box::new(block_import),
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ use sc_client_api::{
|
||||
};
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::{prelude::*, future::BoxFuture};
|
||||
use log::{debug, info, log, trace, warn};
|
||||
use sc_consensus_slots::{
|
||||
SlotWorker, SlotInfo, SlotCompatible, StorageChanges, CheckedHeader, check_equivocation,
|
||||
@@ -1272,6 +1272,7 @@ pub fn import_queue<Block: BlockT, Client, Inner>(
|
||||
finality_proof_import: Option<BoxFinalityProofImport<Block>>,
|
||||
client: Arc<Client>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: impl Fn(BoxFuture<'static, ()>) -> (),
|
||||
) -> ClientResult<BabeImportQueue<Block, sp_api::TransactionFor<Client, Block>>> where
|
||||
Inner: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<Client, Block>>
|
||||
+ Send + Sync + 'static,
|
||||
@@ -1294,6 +1295,7 @@ pub fn import_queue<Block: BlockT, Client, Inner>(
|
||||
Box::new(block_import),
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! A manual sealing engine: the engine listens for rpc calls to seal blocks and create forks.
|
||||
//! This is suitable for a testing environment.
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::{prelude::*, future::BoxFuture};
|
||||
use sp_consensus::{
|
||||
Environment, Proposer, ForkChoiceStrategy, BlockImportParams, BlockOrigin, SelectChain,
|
||||
import_queue::{BasicQueue, CacheKeyId, Verifier, BoxBlockImport},
|
||||
@@ -67,7 +67,8 @@ impl<B: BlockT> Verifier<B> for ManualSealVerifier {
|
||||
|
||||
/// Instantiate the import queue for the manual seal consensus engine.
|
||||
pub fn import_queue<Block, B>(
|
||||
block_import: BoxBlockImport<Block, TransactionFor<B, Block>>
|
||||
block_import: BoxBlockImport<Block, TransactionFor<B, Block>>,
|
||||
spawner: impl Fn(BoxFuture<'static, ()>) -> ()
|
||||
) -> BasicQueue<Block, TransactionFor<B, Block>>
|
||||
where
|
||||
Block: BlockT,
|
||||
@@ -78,6 +79,7 @@ pub fn import_queue<Block, B>(
|
||||
Box::new(block_import),
|
||||
None,
|
||||
None,
|
||||
spawner,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ use codec::{Encode, Decode};
|
||||
use sc_client_api;
|
||||
use log::*;
|
||||
use sp_timestamp::{InherentError as TIError, TimestampInherentData};
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
#[derive(derive_more::Display, Debug)]
|
||||
pub enum Error<B: BlockT> {
|
||||
@@ -461,6 +462,7 @@ pub fn import_queue<B, Transaction, Algorithm>(
|
||||
finality_proof_import: Option<BoxFinalityProofImport<B>>,
|
||||
algorithm: Algorithm,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: impl Fn(BoxFuture<'static, ()>) -> (),
|
||||
) -> Result<
|
||||
PowImportQueue<B, Transaction>,
|
||||
sp_consensus::Error
|
||||
@@ -477,7 +479,8 @@ pub fn import_queue<B, Transaction, Algorithm>(
|
||||
verifier,
|
||||
block_import,
|
||||
justification_import,
|
||||
finality_proof_import
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user