mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 16:11:05 +00:00
Async block import params (#10488)
* Make `SimpleSlotWorker::block_import_params()` return function that returns a future * Simplify `SimpleSlotWorker::block_import_params()` to just async method
This commit is contained in:
@@ -144,24 +144,17 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
fn pre_digest_data(&self, slot: Slot, claim: &Self::Claim) -> Vec<sp_runtime::DigestItem>;
|
||||
|
||||
/// Returns a function which produces a `BlockImportParams`.
|
||||
fn block_import_params(
|
||||
async fn block_import_params(
|
||||
&self,
|
||||
) -> Box<
|
||||
dyn Fn(
|
||||
B::Header,
|
||||
&B::Hash,
|
||||
Vec<B::Extrinsic>,
|
||||
StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>,
|
||||
Self::Claim,
|
||||
Self::EpochData,
|
||||
) -> Result<
|
||||
sc_consensus::BlockImportParams<
|
||||
B,
|
||||
<Self::BlockImport as BlockImport<B>>::Transaction,
|
||||
>,
|
||||
sp_consensus::Error,
|
||||
> + Send
|
||||
+ 'static,
|
||||
header: B::Header,
|
||||
header_hash: &B::Hash,
|
||||
body: Vec<B::Extrinsic>,
|
||||
storage_changes: StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>,
|
||||
public: Self::Claim,
|
||||
epoch: Self::EpochData,
|
||||
) -> Result<
|
||||
sc_consensus::BlockImportParams<B, <Self::BlockImport as BlockImport<B>>::Transaction>,
|
||||
sp_consensus::Error,
|
||||
>;
|
||||
|
||||
/// Whether to force authoring if offline.
|
||||
@@ -342,23 +335,23 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
},
|
||||
};
|
||||
|
||||
let block_import_params_maker = self.block_import_params();
|
||||
let block_import = self.block_import();
|
||||
|
||||
let (block, storage_proof) = (proposal.block, proposal.proof);
|
||||
let (header, body) = block.deconstruct();
|
||||
let header_num = *header.number();
|
||||
let header_hash = header.hash();
|
||||
let parent_hash = *header.parent_hash();
|
||||
|
||||
let block_import_params = match block_import_params_maker(
|
||||
header,
|
||||
&header_hash,
|
||||
body.clone(),
|
||||
proposal.storage_changes,
|
||||
claim,
|
||||
epoch_data,
|
||||
) {
|
||||
let block_import_params = match self
|
||||
.block_import_params(
|
||||
header,
|
||||
&header_hash,
|
||||
body.clone(),
|
||||
proposal.storage_changes,
|
||||
claim,
|
||||
epoch_data,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(bi) => bi,
|
||||
Err(err) => {
|
||||
warn!(target: logging_target, "Failed to create block import params: {:?}", err);
|
||||
@@ -385,7 +378,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
);
|
||||
|
||||
let header = block_import_params.post_header();
|
||||
match block_import.import_block(block_import_params, Default::default()).await {
|
||||
match self.block_import().import_block(block_import_params, Default::default()).await {
|
||||
Ok(res) => {
|
||||
res.handle_justification(
|
||||
&header.hash(),
|
||||
|
||||
Reference in New Issue
Block a user