diff --git a/src/chain/checkpoints.rs b/src/chain/checkpoints.rs index 83181f3f..7f87530a 100644 --- a/src/chain/checkpoints.rs +++ b/src/chain/checkpoints.rs @@ -5,7 +5,7 @@ use bitcoin::{constants::genesis_block, params::Params, BlockHash}; type Height = u32; /// A known block hash in the chain of most work. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct HeaderCheckpoint { /// The index of the block hash. pub height: Height, @@ -45,6 +45,18 @@ impl HeaderCheckpoint { } } +impl std::cmp::PartialOrd for HeaderCheckpoint { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl std::cmp::Ord for HeaderCheckpoint { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.height.cmp(&other.height) + } +} + impl From<(u32, BlockHash)> for HeaderCheckpoint { fn from(value: (u32, BlockHash)) -> Self { HeaderCheckpoint::new(value.0, value.1)