mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 16:51:02 +00:00
BlockId removal: refactor: Backend::append_justification (#12551)
* BlockId removal: refactor: Backend::append_justification It changes the arguments of `Backend::append_justification` from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of `BlockId::Number` refactoring analysis (paritytech/substrate#11292) * Error message improved Co-authored-by: Adrian Catangiu <adrian@parity.io> * single error message in beefy::finalize * println removed Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
committed by
GitHub
parent
9bc59da6b3
commit
0ef7e261a3
@@ -500,20 +500,22 @@ where
|
||||
|
||||
self.on_demand_justifications.cancel_requests_older_than(block_num);
|
||||
|
||||
if let Err(e) = self.backend.append_justification(
|
||||
BlockId::Number(block_num),
|
||||
(BEEFY_ENGINE_ID, finality_proof.encode()),
|
||||
) {
|
||||
if let Err(e) = self
|
||||
.backend
|
||||
.blockchain()
|
||||
.expect_block_hash_from_id(&BlockId::Number(block_num))
|
||||
.and_then(|hash| {
|
||||
self.links
|
||||
.to_rpc_best_block_sender
|
||||
.notify(|| Ok::<_, ()>(hash))
|
||||
.expect("forwards closure result; the closure always returns Ok; qed.");
|
||||
|
||||
self.backend
|
||||
.append_justification(&hash, (BEEFY_ENGINE_ID, finality_proof.encode()))
|
||||
}) {
|
||||
error!(target: "beefy", "🥩 Error {:?} on appending justification: {:?}", e, finality_proof);
|
||||
}
|
||||
|
||||
self.backend.blockchain().hash(block_num).ok().flatten().map(|hash| {
|
||||
self.links
|
||||
.to_rpc_best_block_sender
|
||||
.notify(|| Ok::<_, ()>(hash))
|
||||
.expect("forwards closure result; the closure always returns Ok; qed.")
|
||||
});
|
||||
|
||||
self.links
|
||||
.to_rpc_justif_sender
|
||||
.notify(|| Ok::<_, ()>(finality_proof))
|
||||
@@ -1546,8 +1548,10 @@ pub(crate) mod tests {
|
||||
commitment,
|
||||
signatures: vec![None],
|
||||
});
|
||||
let hashof10 =
|
||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(10)).unwrap();
|
||||
backend
|
||||
.append_justification(BlockId::Number(10), (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.append_justification(&hashof10, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.unwrap();
|
||||
|
||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 10
|
||||
@@ -1580,8 +1584,10 @@ pub(crate) mod tests {
|
||||
commitment,
|
||||
signatures: vec![None],
|
||||
});
|
||||
let hashof12 =
|
||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(12)).unwrap();
|
||||
backend
|
||||
.append_justification(BlockId::Number(12), (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.append_justification(&hashof12, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.unwrap();
|
||||
|
||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 12
|
||||
|
||||
Reference in New Issue
Block a user