From 9c0453c7d9767002b6722c888ac1f694c792c0d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BF=97=E5=AE=87?= Date: Sat, 7 Feb 2026 10:12:00 +0000 Subject: [PATCH] docs(core): Add module-level docs for `checkpoint_entry` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Explain the purpose of `CheckPointEntry` and its two variants: - `Occupied`: real checkpoint at this height - `Placeholder`: implied by `prev_blockhash` from checkpoint above Also fix typo: "atleast" → "at least" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- crates/chain/src/local_chain.rs | 2 +- crates/core/src/checkpoint_entry.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/chain/src/local_chain.rs b/crates/chain/src/local_chain.rs index 4e92e94d..537e910e 100644 --- a/crates/chain/src/local_chain.rs +++ b/crates/chain/src/local_chain.rs @@ -263,7 +263,7 @@ where CheckPoint::from_blocks(blocks) .map(|tip| Self { tip }) .map_err(|err| { - let last_cp = err.expect("must have atleast one block (genesis)"); + let last_cp = err.expect("must have at least one block (genesis)"); ApplyBlockError::PrevBlockhashMismatch { expected: last_cp.block_id(), } diff --git a/crates/core/src/checkpoint_entry.rs b/crates/core/src/checkpoint_entry.rs index 7475e4f4..b0151ec9 100644 --- a/crates/core/src/checkpoint_entry.rs +++ b/crates/core/src/checkpoint_entry.rs @@ -1,3 +1,16 @@ +//! Checkpoint entries for `prev_blockhash`-aware iteration. +//! +//! A [`CheckPoint`] chain may have gaps (non-contiguous heights). However, each checkpoint's +//! data can include a `prev_blockhash` that references the block one height below. This module +//! provides [`CheckPointEntry`], which represents either: +//! +//! - **Occupied**: A real checkpoint stored at this height. +//! - **Placeholder**: No checkpoint exists at this height, but the checkpoint above references it +//! via `prev_blockhash`. The placeholder contains the implied [`BlockId`]. +//! +//! 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; -- 2.49.0