mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-23 22:29:59 -07:00
brk_mempool
Real-time Bitcoin mempool monitoring with fee estimation.
What It Enables
Track mempool state, estimate transaction fees via projected block building, and query address mempool activity. Updates automatically with 1-second sync cycles.
Key Features
- Projected blocks: Simulates Bitcoin Core's block template algorithm with CPFP awareness
- Fee estimation: Multi-tier fee recommendations (fastest, half-hour, hour, economy, minimum)
- Address tracking: Maps addresses to their pending transactions
- Dependency handling: Respects transaction ancestry for accurate fee calculations
- Rate-limited rebuilds: Throttles expensive projections to 1/second
Core API
let mempool = Mempool::new(&rpc_client);
// Start background sync loop
std::thread::spawn(move || mempool.start());
// Query current state
let fees = mempool.get_fees();
let info = mempool.get_info();
let blocks = mempool.get_block_stats();
let snapshot = mempool.get_snapshot();
// Address lookups
let tracker = mempool.get_addresses();
Fee Estimation
Returns RecommendedFees with sat/vB rates for different confirmation targets:
fastest_fee- Next block (index 0)half_hour_fee- ~3 blocks (index 2)hour_fee- ~6 blocks (index 5)economy_fee- ~8 blocks (index 7, last projected block)minimum_fee- Relay minimum
Block Projection
Builds projected blocks by:
- Constructing transaction dependency graph
- Calculating effective fee rates (including ancestors)
- Selecting transactions greedily by ancestor-aware fee rate
- Partitioning into 1MB vsize blocks
Built On
brk_errorfor error handlingbrk_rpcfor mempool RPC callsbrk_typesforMempoolInfo,MempoolEntryInfo,RecommendedFees