Skip to content

Commit

Permalink
node: improve verify_prev_block_cert performance
Browse files Browse the repository at this point in the history
- Fetch the header instead of fetching the full block
- Use the header hash instead of the block height
  • Loading branch information
herr-seppia committed Jul 18, 2024
1 parent bba6683 commit 8e44945
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions node/src/chain/header_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,9 @@ impl<'a, DB: database::DB> Validator<'a, DB> {
}

let prev_block_seed = self.db.read().await.view(|v| {
let prior_tip =
Ledger::fetch_block_by_height(&v, self.prev_header.height - 1)?
.ok_or_else(|| anyhow::anyhow!("could not fetch block"))?;

Ok::<_, anyhow::Error>(prior_tip.header().seed)
v.fetch_block_header(&self.prev_header.prev_block_hash)?
.ok_or_else(|| anyhow::anyhow!("Header not found"))
.map(|h| h.seed)
})?;

let (_, _, voters) = verify_block_att(
Expand Down

0 comments on commit 8e44945

Please sign in to comment.