mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-14 17:55:44 +00:00
proposer: return optional block (#2834)
This opens up the proposer to only optionally create blocks. Nodes may only make blocks when there are transactions or the chain is scheduled. --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -172,12 +172,14 @@ where
|
||||
inherent_data: (ParachainInherentData, InherentData),
|
||||
proposal_duration: Duration,
|
||||
max_pov_size: usize,
|
||||
) -> Result<(Collation, ParachainBlockData<Block>, Block::Hash), Box<dyn Error + Send + 'static>>
|
||||
{
|
||||
) -> Result<
|
||||
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
|
||||
Box<dyn Error + Send + 'static>,
|
||||
> {
|
||||
let mut digest = additional_pre_digest.into().unwrap_or_default();
|
||||
digest.push(slot_claim.pre_digest.clone());
|
||||
|
||||
let proposal = self
|
||||
let maybe_proposal = self
|
||||
.proposer
|
||||
.propose(
|
||||
&parent_header,
|
||||
@@ -190,6 +192,11 @@ where
|
||||
.await
|
||||
.map_err(|e| Box::new(e) as Box<dyn Error + Send>)?;
|
||||
|
||||
let proposal = match maybe_proposal {
|
||||
None => return Ok(None),
|
||||
Some(p) => p,
|
||||
};
|
||||
|
||||
let sealed_importable = seal::<_, P>(
|
||||
proposal.block,
|
||||
proposal.storage_changes,
|
||||
@@ -234,7 +241,7 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
Ok((collation, block_data, post_hash))
|
||||
Ok(Some((collation, block_data, post_hash)))
|
||||
} else {
|
||||
Err(Box::<dyn Error + Send + Sync>::from("Unable to produce collation")
|
||||
as Box<dyn Error + Send>)
|
||||
|
||||
Reference in New Issue
Block a user