mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Expose that BasicQueue expects blocking spawn (#5860)
* Expose that `BasicQueue` expects blocking spawn Up to now `BasicQueue` expected a closure that to spawn a `Future`. This was expected to be a closure that spawns a blocking future. However, this wasn't documented anywhere. This pr introduces a new trait `SpawnBlocking` that exposes this requirement to the outside. * Feedback
This commit is contained in:
@@ -33,7 +33,7 @@ use std::{
|
||||
collections::HashMap
|
||||
};
|
||||
|
||||
use futures::{prelude::*, future::BoxFuture};
|
||||
use futures::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use log::{debug, info, trace};
|
||||
|
||||
@@ -788,14 +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, F>(
|
||||
pub fn import_queue<B, I, C, P, S>(
|
||||
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,
|
||||
spawner: &S,
|
||||
) -> 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>,
|
||||
@@ -805,7 +805,7 @@ pub fn import_queue<B, I, C, P, F>(
|
||||
P: Pair + Send + Sync + 'static,
|
||||
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
|
||||
P::Signature: Encode + Decode,
|
||||
F: Fn(BoxFuture<'static, ()>) -> (),
|
||||
S: sp_core::traits::SpawnBlocking,
|
||||
{
|
||||
register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?;
|
||||
initialize_authorities_cache(&*client)?;
|
||||
@@ -815,6 +815,7 @@ pub fn import_queue<B, I, C, P, F>(
|
||||
inherent_data_providers,
|
||||
phantom: PhantomData,
|
||||
};
|
||||
|
||||
Ok(BasicQueue::new(
|
||||
verifier,
|
||||
Box::new(block_import),
|
||||
|
||||
@@ -107,7 +107,7 @@ use sc_client_api::{
|
||||
};
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
use futures::{prelude::*, future::BoxFuture};
|
||||
use futures::prelude::*;
|
||||
use log::{debug, info, log, trace, warn};
|
||||
use sc_consensus_slots::{
|
||||
SlotWorker, SlotInfo, SlotCompatible, StorageChanges, CheckedHeader, check_equivocation,
|
||||
@@ -1272,7 +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, ()>) -> (),
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
) -> ClientResult<BabeImportQueue<Block, sp_api::TransactionFor<Client, Block>>> where
|
||||
Inner: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<Client, Block>>
|
||||
+ Send + Sync + 'static,
|
||||
|
||||
@@ -28,6 +28,7 @@ sp-blockchain = { path = "../../../primitives/blockchain" , version = "2.0.0-dev
|
||||
sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" , version = "0.8.0-dev"}
|
||||
sp-inherents = { path = "../../../primitives/inherents" , version = "2.0.0-dev"}
|
||||
sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-dev"}
|
||||
sp-core = { path = "../../../primitives/core" , version = "2.0.0-dev"}
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool" , version = "2.0.0-dev"}
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -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::*, future::BoxFuture};
|
||||
use futures::prelude::*;
|
||||
use sp_consensus::{
|
||||
Environment, Proposer, ForkChoiceStrategy, BlockImportParams, BlockOrigin, SelectChain,
|
||||
import_queue::{BasicQueue, CacheKeyId, Verifier, BoxBlockImport},
|
||||
@@ -68,7 +68,7 @@ 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>>,
|
||||
spawner: impl Fn(BoxFuture<'static, ()>) -> ()
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
) -> BasicQueue<Block, TransactionFor<B, Block>>
|
||||
where
|
||||
Block: BlockT,
|
||||
|
||||
@@ -49,12 +49,13 @@ use sp_consensus::{
|
||||
SelectChain, Error as ConsensusError, CanAuthorWith, RecordProof, BlockImport,
|
||||
BlockCheckParams, ImportResult,
|
||||
};
|
||||
use sp_consensus::import_queue::{BoxBlockImport, BasicQueue, Verifier, BoxJustificationImport, BoxFinalityProofImport};
|
||||
use sp_consensus::import_queue::{
|
||||
BoxBlockImport, BasicQueue, Verifier, BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
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> {
|
||||
@@ -462,7 +463,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, ()>) -> (),
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
) -> Result<
|
||||
PowImportQueue<B, Transaction>,
|
||||
sp_consensus::Error
|
||||
|
||||
Reference in New Issue
Block a user