19 releases
Uses new Rust 2024
| 0.1.9 | Feb 13, 2026 |
|---|---|
| 0.1.8 | Feb 13, 2026 |
| 0.1.2 | Jan 29, 2026 |
| 0.1.0-alpha.1 | Dec 21, 2025 |
#85 in #on-chain
35 downloads per month
Used in 8 crates
(4 directly)
575KB
18K
SLoC
brk_iterator
Unified block iteration with automatic source selection.
What It Enables
Iterate over Bitcoin blocks with a simple API that automatically chooses between RPC (for small ranges) and direct blk file reading (for large scans). Handles reorgs gracefully.
Key Features
- Smart source selection: RPC for ≤10 blocks, Reader for larger ranges
- Flexible ranges: By height span, from start, to end, last N blocks, or after hash
- Reorg-safe: Iteration may end early if chain reorganizes
- Thread-safe: Clone and share freely
Core API
let blocks = Blocks::new(&rpc_client, &reader);
// Various range specifications
for block in blocks.range(Height::new(800_000), Height::new(800_100))? { ... }
for block in blocks.start(Height::new(840_000))? { ... }
for block in blocks.last(10)? { ... }
for block in blocks.after(Some(last_known_hash))? { ... }
Source Modes
// Auto-select (default)
let blocks = Blocks::new(&client, &reader);
// Force RPC only
let blocks = Blocks::new_rpc(&client);
// Force Reader only
let blocks = Blocks::new_reader(&reader);
Range Types
| Method | Description |
|---|---|
range(start, end) |
Inclusive height range |
start(height) |
From height to chain tip |
end(height) |
From genesis to height |
last(n) |
Last n blocks from tip |
after(hash) |
All blocks after given hash |
Built On
brk_errorfor error handlingbrk_readerfor direct blk file accessbrk_rpcfor RPC queriesbrk_typesforHeight,BlockHash
Dependencies
~33MB
~477K SLoC