mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 16:51:03 +00:00
Allow specifying immediate finalize for manual-seal (#12106)
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -247,6 +247,60 @@ pub async fn run_instant_seal<B, BI, CB, E, C, TP, SC, CIDP, P>(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runs the background authorship task for the instant seal engine.
|
||||||
|
/// instant-seal creates a new block for every transaction imported into
|
||||||
|
/// the transaction pool.
|
||||||
|
///
|
||||||
|
/// This function will finalize the block immediately as well. If you don't
|
||||||
|
/// want this behavior use `run_instant_seal` instead.
|
||||||
|
pub async fn run_instant_seal_and_finalize<B, BI, CB, E, C, TP, SC, CIDP, P>(
|
||||||
|
InstantSealParams {
|
||||||
|
block_import,
|
||||||
|
env,
|
||||||
|
client,
|
||||||
|
pool,
|
||||||
|
select_chain,
|
||||||
|
consensus_data_provider,
|
||||||
|
create_inherent_data_providers,
|
||||||
|
}: InstantSealParams<B, BI, E, C, TP, SC, CIDP, P>,
|
||||||
|
) where
|
||||||
|
B: BlockT + 'static,
|
||||||
|
BI: BlockImport<B, Error = sp_consensus::Error, Transaction = sp_api::TransactionFor<C, B>>
|
||||||
|
+ Send
|
||||||
|
+ Sync
|
||||||
|
+ 'static,
|
||||||
|
C: HeaderBackend<B> + Finalizer<B, CB> + ProvideRuntimeApi<B> + 'static,
|
||||||
|
CB: ClientBackend<B> + 'static,
|
||||||
|
E: Environment<B> + 'static,
|
||||||
|
E::Proposer: Proposer<B, Proof = P, Transaction = TransactionFor<C, B>>,
|
||||||
|
SC: SelectChain<B> + 'static,
|
||||||
|
TransactionFor<C, B>: 'static,
|
||||||
|
TP: TransactionPool<Block = B>,
|
||||||
|
CIDP: CreateInherentDataProviders<B, ()>,
|
||||||
|
P: Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
// Creates and finalizes blocks as soon as transactions are imported
|
||||||
|
// into the transaction pool.
|
||||||
|
let commands_stream = pool.import_notification_stream().map(|_| EngineCommand::SealNewBlock {
|
||||||
|
create_empty: false,
|
||||||
|
finalize: true,
|
||||||
|
parent_hash: None,
|
||||||
|
sender: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
run_manual_seal(ManualSealParams {
|
||||||
|
block_import,
|
||||||
|
env,
|
||||||
|
client,
|
||||||
|
pool,
|
||||||
|
commands_stream,
|
||||||
|
select_chain,
|
||||||
|
consensus_data_provider,
|
||||||
|
create_inherent_data_providers,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
Reference in New Issue
Block a user