Skip to content

Commit

Permalink
Implement Anchor for BlockId
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirfomene committed Aug 9, 2023
1 parent feafaac commit 6328bd1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/chain/src/chain_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl From<ChainPosition<ConfirmationTimeAnchor>> for ConfirmationTime {
}

/// A reference to a block in the canonical chain.
/// When used as an anchor block, it is the same as the confirmation block.
#[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
#[cfg_attr(
feature = "serde",
Expand All @@ -100,6 +101,13 @@ pub struct BlockId {
pub hash: BlockHash,
}

impl Anchor for BlockId {
// Here the returned anchored [`BlockId`] is the same as confirmation block.
fn anchor_block(&self) -> Self {
*self
}
}

impl Default for BlockId {
fn default() -> Self {
Self {
Expand Down

0 comments on commit 6328bd1

Please sign in to comment.