]> Untitled Git - bdk/commitdiff
feat: Implement Anchor for BlockId
authorVladimir Fomene <vladimirfomene@gmail.com>
Wed, 9 Aug 2023 07:42:47 +0000 (10:42 +0300)
committerVladimir Fomene <vladimirfomene@gmail.com>
Wed, 16 Aug 2023 15:55:26 +0000 (18:55 +0300)
crates/chain/src/chain_data.rs

index 16877637072d6290013ec338cfcdb10e6a306178..c5de09bb1d2a2b987d3f0c07b60ff7ae4952c23d 100644 (file)
@@ -87,6 +87,9 @@ impl From<ChainPosition<ConfirmationTimeAnchor>> for ConfirmationTime {
 }
 
 /// A reference to a block in the canonical chain.
+///
+/// `BlockId` implements [`Anchor`]. When a transaction is anchored to `BlockId`, the confirmation
+/// block and anchor block are the same block.
 #[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
 #[cfg_attr(
     feature = "serde",
@@ -100,6 +103,12 @@ pub struct BlockId {
     pub hash: BlockHash,
 }
 
+impl Anchor for BlockId {
+    fn anchor_block(&self) -> Self {
+        *self
+    }
+}
+
 impl Default for BlockId {
     fn default() -> Self {
         Self {