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:
Michal Kucharczyk
2022-10-20 08:44:04 +02:00
committed by GitHub
parent 7aadc2aa3c
commit 749bcd1949
16 changed files with 113 additions and 118 deletions
+8 -15
View File
@@ -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)
}
}