Skip to content

Commit

Permalink
Remove unused finalization_displaced variable in db (paritytech#13090)
Browse files Browse the repository at this point in the history
  • Loading branch information
skunert authored and ltfschoen committed Feb 22, 2023
1 parent e69a24b commit 0890d78
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,14 +1291,13 @@ impl<Block: BlockT> Backend<Block> {
header: &Block::Header,
last_finalized: Option<Block::Hash>,
justification: Option<Justification>,
finalization_displaced: &mut Option<FinalizationOutcome<Block::Hash, NumberFor<Block>>>,
) -> ClientResult<MetaUpdate<Block>> {
// TODO: ensure best chain contains this block.
let number = *header.number();
self.ensure_sequential_finalization(header, last_finalized)?;
let with_state = sc_client_api::Backend::have_state_at(self, hash, number);

self.note_finalized(transaction, header, hash, finalization_displaced, with_state)?;
self.note_finalized(transaction, header, hash, with_state)?;

if let Some(justification) = justification {
transaction.set_from_vec(
Expand Down Expand Up @@ -1362,7 +1361,6 @@ impl<Block: BlockT> Backend<Block> {

fn try_commit_operation(&self, mut operation: BlockImportOperation<Block>) -> ClientResult<()> {
let mut transaction = Transaction::new();
let mut finalization_displaced_leaves = None;

operation.apply_aux(&mut transaction);
operation.apply_offchain(&mut transaction);
Expand All @@ -1381,7 +1379,6 @@ impl<Block: BlockT> Backend<Block> {
&block_header,
Some(last_finalized_hash),
justification,
&mut finalization_displaced_leaves,
)?);
last_finalized_hash = block_hash;
last_finalized_num = *block_header.number();
Expand Down Expand Up @@ -1554,13 +1551,7 @@ impl<Block: BlockT> Backend<Block> {
if finalized {
// TODO: ensure best chain contains this block.
self.ensure_sequential_finalization(header, Some(last_finalized_hash))?;
self.note_finalized(
&mut transaction,
header,
hash,
&mut finalization_displaced_leaves,
operation.commit_state,
)?;
self.note_finalized(&mut transaction, header, hash, operation.commit_state)?;
} else {
// canonicalize blocks which are old enough, regardless of finality.
self.force_delayed_canonicalize(&mut transaction)?
Expand Down Expand Up @@ -1692,7 +1683,6 @@ impl<Block: BlockT> Backend<Block> {
transaction: &mut Transaction<DbHash>,
f_header: &Block::Header,
f_hash: Block::Hash,
displaced: &mut Option<FinalizationOutcome<Block::Hash, NumberFor<Block>>>,
with_state: bool,
) -> ClientResult<()> {
let f_num = *f_header.number();
Expand Down Expand Up @@ -1720,10 +1710,6 @@ impl<Block: BlockT> Backend<Block> {

let new_displaced = self.blockchain.leaves.write().finalize_height(f_num);
self.prune_blocks(transaction, f_num, &new_displaced)?;
match displaced {
x @ &mut None => *x = Some(new_displaced),
&mut Some(ref mut displaced) => displaced.merge(new_displaced),
}

Ok(())
}
Expand Down Expand Up @@ -2013,16 +1999,15 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
) -> ClientResult<()> {
let mut transaction = Transaction::new();
let header = self.blockchain.expect_header(hash)?;
let mut displaced = None;

let m = self.finalize_block_with_transaction(
&mut transaction,
hash,
&header,
None,
justification,
&mut displaced,
)?;

self.storage.db.commit(transaction)?;
self.blockchain.update_meta(m);
Ok(())
Expand Down

0 comments on commit 0890d78

Please sign in to comment.