mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 14:35:40 +00:00
BlockId removal: refactor: Finalizer (#12528)
* BlockId removal: refactor: Finalizer It changes the arguments of methods of `Finalizer` trait from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * minor corrections * failing test corrected * minor rework
This commit is contained in:
committed by
GitHub
parent
7aadc2aa3c
commit
749bcd1949
@@ -1845,29 +1845,22 @@ where
|
||||
fn apply_finality(
|
||||
&self,
|
||||
operation: &mut ClientImportOperation<Block, B>,
|
||||
id: BlockId<Block>,
|
||||
hash: &Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
notify: bool,
|
||||
) -> sp_blockchain::Result<()> {
|
||||
let last_best = self.backend.blockchain().info().best_hash;
|
||||
let to_finalize_hash = self.backend.blockchain().expect_block_hash_from_id(&id)?;
|
||||
self.apply_finality_with_block_hash(
|
||||
operation,
|
||||
to_finalize_hash,
|
||||
justification,
|
||||
last_best,
|
||||
notify,
|
||||
)
|
||||
self.apply_finality_with_block_hash(operation, *hash, justification, last_best, notify)
|
||||
}
|
||||
|
||||
fn finalize_block(
|
||||
&self,
|
||||
id: BlockId<Block>,
|
||||
hash: &Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
notify: bool,
|
||||
) -> sp_blockchain::Result<()> {
|
||||
self.lock_import_and_run(|operation| {
|
||||
self.apply_finality(operation, id, justification, notify)
|
||||
self.apply_finality(operation, hash, justification, notify)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1881,20 +1874,20 @@ where
|
||||
fn apply_finality(
|
||||
&self,
|
||||
operation: &mut ClientImportOperation<Block, B>,
|
||||
id: BlockId<Block>,
|
||||
hash: &Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
notify: bool,
|
||||
) -> sp_blockchain::Result<()> {
|
||||
(**self).apply_finality(operation, id, justification, notify)
|
||||
(**self).apply_finality(operation, hash, justification, notify)
|
||||
}
|
||||
|
||||
fn finalize_block(
|
||||
&self,
|
||||
id: BlockId<Block>,
|
||||
hash: &Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
notify: bool,
|
||||
) -> sp_blockchain::Result<()> {
|
||||
(**self).finalize_block(id, justification, notify)
|
||||
(**self).finalize_block(hash, justification, notify)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -867,7 +867,7 @@ fn import_with_justification() {
|
||||
.unwrap()
|
||||
.block;
|
||||
block_on(client.import(BlockOrigin::Own, a2.clone())).unwrap();
|
||||
client.finalize_block(BlockId::hash(a2.hash()), None).unwrap();
|
||||
client.finalize_block(&a2.hash(), None).unwrap();
|
||||
|
||||
// A2 -> A3
|
||||
let justification = Justifications::from((TEST_ENGINE_ID, vec![1, 2, 3]));
|
||||
@@ -996,7 +996,7 @@ fn finalizing_diverged_block_should_trigger_reorg() {
|
||||
|
||||
// we finalize block B1 which is on a different branch from current best
|
||||
// which should trigger a re-org.
|
||||
ClientExt::finalize_block(&client, BlockId::Hash(b1.hash()), None).unwrap();
|
||||
ClientExt::finalize_block(&client, &b1.hash(), None).unwrap();
|
||||
|
||||
// B1 should now be the latest finalized
|
||||
assert_eq!(client.chain_info().finalized_hash, b1.hash());
|
||||
@@ -1020,7 +1020,7 @@ fn finalizing_diverged_block_should_trigger_reorg() {
|
||||
|
||||
assert_eq!(client.chain_info().best_hash, b3.hash());
|
||||
|
||||
ClientExt::finalize_block(&client, BlockId::Hash(b3.hash()), None).unwrap();
|
||||
ClientExt::finalize_block(&client, &b3.hash(), None).unwrap();
|
||||
|
||||
finality_notification_check(&mut finality_notifications, &[b1.hash()], &[]);
|
||||
finality_notification_check(&mut finality_notifications, &[b2.hash(), b3.hash()], &[a2.hash()]);
|
||||
@@ -1118,7 +1118,7 @@ fn finality_notifications_content() {
|
||||
|
||||
// Postpone import to test behavior of import of finalized block.
|
||||
|
||||
ClientExt::finalize_block(&client, BlockId::Hash(a2.hash()), None).unwrap();
|
||||
ClientExt::finalize_block(&client, &a2.hash(), None).unwrap();
|
||||
|
||||
// Import and finalize D4
|
||||
block_on(client.import_as_final(BlockOrigin::Own, d4.clone())).unwrap();
|
||||
@@ -1274,7 +1274,7 @@ fn doesnt_import_blocks_that_revert_finality() {
|
||||
|
||||
// we will finalize A2 which should make it impossible to import a new
|
||||
// B3 at the same height but that doesn't include it
|
||||
ClientExt::finalize_block(&client, BlockId::Hash(a2.hash()), None).unwrap();
|
||||
ClientExt::finalize_block(&client, &a2.hash(), None).unwrap();
|
||||
|
||||
let import_err = block_on(client.import(BlockOrigin::Own, b3)).err().unwrap();
|
||||
let expected_err =
|
||||
@@ -1309,7 +1309,7 @@ fn doesnt_import_blocks_that_revert_finality() {
|
||||
.unwrap()
|
||||
.block;
|
||||
block_on(client.import(BlockOrigin::Own, a3.clone())).unwrap();
|
||||
ClientExt::finalize_block(&client, BlockId::Hash(a3.hash()), None).unwrap();
|
||||
ClientExt::finalize_block(&client, &a3.hash(), None).unwrap();
|
||||
|
||||
finality_notification_check(&mut finality_notifications, &[a1.hash(), a2.hash()], &[]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user