pub struct BlockIndexEntry {
pub hash: [u8; 32],
pub height: u32,
pub status: u32,
pub n_file: u32,
pub n_data_pos: u32,
}Expand description
Represents a CDiskBlockIndex entry from Bitcoin Core.
Fields§
§hash: [u8; 32]Block hash (32 bytes, Bitcoin Core internal format — little-endian)
height: u32Block height in the chain
status: u32Bitcoin Core status field:
- bits 0–2: validity level (0=unknown, 1=header, 2=tree, 3=transactions, 4=chain/BLOCK_VALID_CHAIN, 5=scripts/BLOCK_VALID_SCRIPTS)
- bit 3 (0x08): BLOCK_HAVE_DATA — block data is in blk*.dat
- bit 4 (0x10): BLOCK_HAVE_UNDO — undo data is in rev*.dat
n_file: u32blk*.dat file index (0 → blk00000.dat)
n_data_pos: u32Byte offset within the blk{n_file:05}.dat file where the block starts
Implementations§
Source§impl BlockIndexEntry
impl BlockIndexEntry
Sourcepub fn is_valid_and_available(&self) -> bool
pub fn is_valid_and_available(&self) -> bool
Returns true if the block is validated in the chain and the data is available on disk.
Requires:
- Validity level ≥ 4 (BLOCK_VALID_CHAIN): bits 0–2 ≥ 4
- BLOCK_HAVE_DATA (bit 3): data present in blk*.dat
Note: using status & 0x04 would be incorrect — it would only check bit 2, which is
true for any level ≥ 4 (binary …1xx), but also for level 6+ or
invalid combinations. The correct way isolates the 3 validity bits with & 0x07.
Sourcepub fn validity_level(&self) -> u32
pub fn validity_level(&self) -> u32
Returns the block’s validity level (bits 0–2 of status).
Trait Implementations§
Source§impl Clone for BlockIndexEntry
impl Clone for BlockIndexEntry
Source§fn clone(&self) -> BlockIndexEntry
fn clone(&self) -> BlockIndexEntry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BlockIndexEntry
impl RefUnwindSafe for BlockIndexEntry
impl Send for BlockIndexEntry
impl Sync for BlockIndexEntry
impl Unpin for BlockIndexEntry
impl UnsafeUnpin for BlockIndexEntry
impl UnwindSafe for BlockIndexEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more