Crates.io | bitcoin-block-parser |
lib.rs | bitcoin-block-parser |
version | 0.5.2 |
source | src |
created_at | 2024-09-13 18:26:12.981852 |
updated_at | 2024-11-23 21:27:51.285301 |
description | Fast optimized parser for the bitcoin `blocks` data with UTXO tracking. |
homepage | |
repository | https://github.com/sumopool/bitcoin-block-parser |
max_upload_size | |
id | 1374051 |
size | 76,244 |
Fast optimized parser for bitcoin blocks
with input and output tracking.
⚠️ The API is still evolving and should not be considered stable until release 1.0.0
Block
format for easier manipulationTxOut
is spent or unspent for calculations on the UTXO setAmount
of every TxIn
for calculating metrics such as fee ratesFunction | Time | Memory |
---|---|---|
BlockParser::parse() Parses blocks |
2m 55s | 0.9 GB |
UtxoParser::parse() Tracks input amounts (no filter) |
7m 13s | 25.0 GB |
UtxoParser::create_filter() Creates new filter |
16m 09s | 5.6 GB |
UtxoParser::load_filter().parse() Tracks input & outputs (with filter) |
7m 46s | 11.8 GB |
Our benchmarks were run on NVMe storage with a 32-thread processor on 800,000 blocks.
See BlockParser
for details on how to parse blocks:
use bitcoin_block_parser::*;
// Initialize a logger (if you want to monitor parsing progress)
env_logger::builder().filter_level(log::LevelFilter::Info).init();
// Parse all blocks in the directory and map them to total_size
let parser = BlockParser::new("/home/user/.bitcoin/blocks/").unwrap();
for size in parser.parse(|block| block.total_size()) {
// Do something with the block sizes
}
See UtxoParser
for details on how to track inputs and outputs:
use bitcoin_block_parser::*;
let parser = UtxoParser::new("/home/user/.bitcoin/blocks/").unwrap();
// Load a filter file or create a new one for tracking output status
let blocks = parser.load_or_create_filter("filter.bin").unwrap();
for txdata in blocks.parse(|block| block.txdata) {
for tx in txdata {
for (output, status) in tx.output() {
// Do something with the output status
}
for (input, amount) in tx.input() {
// Do something with the input amounts
}
}
}