Skip to content

Commit

Permalink
feat: add parent_num_hash to BlockHeader (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Nov 25, 2024
1 parent 89132da commit 804de17
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/consensus/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,13 @@ pub trait BlockHeader {
base_fee_params,
))
}

/// Returns the parent block's number and hash
///
/// Note: for the genesis block the parent number is 0 and the parent hash is the zero hash.
fn parent_num_hash(&self) -> BlockNumHash {
BlockNumHash { number: self.number().saturating_sub(1), hash: self.parent_hash() }
}
}

impl BlockHeader for Header {
Expand Down

0 comments on commit 804de17

Please sign in to comment.