mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
1.3 KiB
1.3 KiB
brk_monitor
A lightweight, thread-safe Rust library for maintaining a live, in-memory snapshot of the Bitcoin mempool.
Key Features
- Real-time synchronization: Polls Bitcoin Core RPC every second to track mempool state
- Thread-safe access: Uses
RwLockfor concurrent reads with minimal contention - Efficient updates: Only fetches new transactions, with configurable rate limiting (10,000 tx/cycle)
- Zero-copy reads: Exposes mempool via read guards for lock-free iteration
- Optimized data structures: Uses
FxHashMapfor fast lookups and minimal hashing overhead - Automatic cleanup: Removes confirmed/dropped transactions on each update
Design Principles
- Minimal lock duration: Lock held only during HashSet operations, never during I/O
- Memory efficient: Stores only missing txids during fetch phase
- Simple API: Just
new(),start(), andget_txs() - Production-ready: Error handling with logging, graceful degradation
Use Cases
- Fee estimation and mempool analysis
- Transaction monitoring and alerts
- Block template prediction
- Network research and statistics
Description
A clean, performant way to keep Bitcoin's mempool state available in your Rust application without repeatedly querying RPC. Perfect for applications that need frequent mempool access with low latency.