From 0257c549d0602bfcf016be713f281443a0d85a78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BF=97=E5=AE=87?= Date: Mon, 4 May 2026 09:08:23 +0000 Subject: [PATCH] feat(core)!: Remove unused methods of `CheckPointEntry` --- crates/core/src/checkpoint_entry.rs | 58 ----------------------------- 1 file changed, 58 deletions(-) diff --git a/crates/core/src/checkpoint_entry.rs b/crates/core/src/checkpoint_entry.rs index 675a226f..a852669c 100644 --- a/crates/core/src/checkpoint_entry.rs +++ b/crates/core/src/checkpoint_entry.rs @@ -11,8 +11,6 @@ //! Use [`CheckPoint::entry_iter`] to iterate over entries, which yields placeholders for any //! gaps where `prev_blockhash` implies a block. -use core::ops::RangeBounds; - use bitcoin::BlockHash; use crate::{BlockId, CheckPoint, ToBlockHash}; @@ -138,62 +136,6 @@ impl CheckPointEntry { checkpoint_above: checkpoint.clone(), }) } - - /// Iterate over checkpoint entries backwards. - pub fn iter(&self) -> CheckPointEntryIter - where - D: Clone, - { - self.clone().into_iter() - } - - /// Get checkpoint entry at `height`. - /// - /// Returns `None` if checkpoint at `height` does not exist. - pub fn get(&self, height: u32) -> Option - where - D: Clone, - { - self.range(height..=height).next() - } - - /// Iterate checkpoints over a height range. - pub fn range(&self, range: R) -> impl Iterator> - where - D: Clone, - R: RangeBounds, - { - let start_bound = range.start_bound().cloned(); - let end_bound = range.end_bound().cloned(); - self.iter() - .skip_while(move |cp_entry| match end_bound { - core::ops::Bound::Included(inc_bound) => cp_entry.height() > inc_bound, - core::ops::Bound::Excluded(exc_bound) => cp_entry.height() >= exc_bound, - core::ops::Bound::Unbounded => false, - }) - .take_while(move |cp_entry| match start_bound { - core::ops::Bound::Included(inc_bound) => cp_entry.height() >= inc_bound, - core::ops::Bound::Excluded(exc_bound) => cp_entry.height() > exc_bound, - core::ops::Bound::Unbounded => true, - }) - } - - /// Returns the entry at `height` if one exists, otherwise the nearest checkpoint at a lower - /// height. - pub fn floor_at(&self, height: u32) -> Option - where - D: Clone, - { - self.range(..=height).next() - } - - /// Returns the entry located a number of heights below this one. - pub fn floor_below(&self, offset: u32) -> Option - where - D: Clone, - { - self.floor_at(self.height().checked_sub(offset)?) - } } /// Iterates over checkpoint entries backwards. -- 2.49.0