Skip to content

Commit 480c273

Browse files
feat: Implement Anchor for BlockId
1 parent 0cd2348 commit 480c273

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/chain/src/chain_data.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ impl From<ChainPosition<ConfirmationTimeAnchor>> for ConfirmationTime {
8787
}
8888

8989
/// A reference to a block in the canonical chain.
90+
///
91+
/// `BlockId` implements [`Anchor`]. When a transaction is anchored to `BlockId`, the confirmation
92+
/// block and anchor block are the same block.
9093
#[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
9194
#[cfg_attr(
9295
feature = "serde",
@@ -100,6 +103,12 @@ pub struct BlockId {
100103
pub hash: BlockHash,
101104
}
102105

106+
impl Anchor for BlockId {
107+
fn anchor_block(&self) -> Self {
108+
*self
109+
}
110+
}
111+
103112
impl Default for BlockId {
104113
fn default() -> Self {
105114
Self {

0 commit comments

Comments
 (0)