mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 10:01:02 +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:
@@ -203,7 +203,7 @@ where
|
||||
.await
|
||||
);
|
||||
|
||||
let (collation, _, post_hash) = try_request!(
|
||||
let maybe_collation = try_request!(
|
||||
collator
|
||||
.collate(
|
||||
&parent_header,
|
||||
@@ -220,8 +220,14 @@ where
|
||||
.await
|
||||
);
|
||||
|
||||
let result_sender = Some(collator.collator_service().announce_with_barrier(post_hash));
|
||||
request.complete(Some(CollationResult { collation, result_sender }));
|
||||
if let Some((collation, _, post_hash)) = maybe_collation {
|
||||
let result_sender =
|
||||
Some(collator.collator_service().announce_with_barrier(post_hash));
|
||||
request.complete(Some(CollationResult { collation, result_sender }));
|
||||
} else {
|
||||
request.complete(None);
|
||||
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ where
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok((collation, block_data, new_block_hash)) => {
|
||||
Ok(Some((collation, block_data, new_block_hash))) => {
|
||||
// Here we are assuming that the import logic protects against equivocations
|
||||
// and provides sybil-resistance, as it should.
|
||||
collator.collator_service().announce_block(new_block_hash, None);
|
||||
@@ -387,6 +387,10 @@ where
|
||||
parent_hash = new_block_hash;
|
||||
parent_header = block_data.into_header();
|
||||
},
|
||||
Ok(None) => {
|
||||
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
|
||||
break
|
||||
},
|
||||
Err(err) => {
|
||||
tracing::error!(target: crate::LOG_TARGET, ?err);
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user