Skip to content

Commit

Permalink
feat: add Header::num_hash_slow (alloy-rs#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored and lwedge99 committed Oct 8, 2024
1 parent e5e17c2 commit 22f76fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,19 @@ impl Header {
}

/// 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.
pub const fn parent_num_hash(&self) -> BlockNumHash {
BlockNumHash { number: self.number.saturating_sub(1), hash: self.parent_hash }
}

/// Returns the block's number and hash.
///
/// Note: this hashes the header.
pub fn num_hash_slow(&self) -> BlockNumHash {
BlockNumHash { number: self.number, hash: self.hash_slow() }
}

/// Checks if the block's difficulty is set to zero, indicating a Proof-of-Stake header.
///
/// This function is linked to EIP-3675, proposing the consensus upgrade to Proof-of-Stake:
Expand Down

0 comments on commit 22f76fe

Please sign in to comment.