feat: Implement Anchor for BlockId

This commit is contained in:
Vladimir Fomene 2023-08-09 10:42:47 +03:00
parent 0cd2348166
commit 480c2730de
No known key found for this signature in database
GPG Key ID: 4D8AB1DF0F7BFBC3

View File

@ -87,6 +87,9 @@ impl From<ChainPosition<ConfirmationTimeAnchor>> for ConfirmationTime {
} }
/// A reference to a block in the canonical chain. /// 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)] #[derive(Debug, Clone, PartialEq, Eq, Copy, PartialOrd, Ord, core::hash::Hash)]
#[cfg_attr( #[cfg_attr(
feature = "serde", feature = "serde",
@ -100,6 +103,12 @@ pub struct BlockId {
pub hash: BlockHash, pub hash: BlockHash,
} }
impl Anchor for BlockId {
fn anchor_block(&self) -> Self {
*self
}
}
impl Default for BlockId { impl Default for BlockId {
fn default() -> Self { fn default() -> Self {
Self { Self {