mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-19 22:34:46 -07:00
global: fixes
This commit is contained in:
@@ -15,58 +15,52 @@ fn main() -> Result<()> {
|
||||
|
||||
let mempool = Mempool::new(&client);
|
||||
|
||||
// Start mempool sync in background thread
|
||||
let mempool_clone = mempool.clone();
|
||||
thread::spawn(move || {
|
||||
mempool_clone.start();
|
||||
});
|
||||
|
||||
// Poll and display stats every 5 seconds
|
||||
loop {
|
||||
thread::sleep(Duration::from_secs(5));
|
||||
|
||||
// Basic mempool info
|
||||
let info = mempool.info();
|
||||
let block_stats = mempool.block_stats();
|
||||
let total_fees: u64 = block_stats.iter().map(|s| u64::from(s.total_fee)).sum();
|
||||
println!("\n=== Mempool Info ===");
|
||||
println!(" Transactions: {}", info.count);
|
||||
println!(" Total vsize: {} vB", info.vsize);
|
||||
println!(
|
||||
" Total fees: {:.4} BTC",
|
||||
total_fees as f64 / 100_000_000.0
|
||||
);
|
||||
|
||||
// Fee recommendations (like mempool.space)
|
||||
let fees = mempool.fees();
|
||||
println!("\n=== Recommended Fees (sat/vB) ===");
|
||||
println!(" No Priority {:.4}", f64::from(fees.economy_fee));
|
||||
println!(" Low Priority {:.4}", f64::from(fees.hour_fee));
|
||||
println!(" Medium Priority {:.4}", f64::from(fees.half_hour_fee));
|
||||
println!(" High Priority {:.4}", f64::from(fees.fastest_fee));
|
||||
|
||||
// Projected blocks (like mempool.space)
|
||||
if !block_stats.is_empty() {
|
||||
println!("\n=== Projected Blocks ===");
|
||||
for (i, stats) in block_stats.iter().enumerate() {
|
||||
let total_fee_btc = u64::from(stats.total_fee) as f64 / 100_000_000.0;
|
||||
println!(
|
||||
" Block {}: ~{:.4} sat/vB, {:.4}-{:.4} sat/vB, {:.3} BTC, {} txs",
|
||||
i + 1,
|
||||
f64::from(stats.median_fee_rate()),
|
||||
f64::from(stats.min_fee_rate()),
|
||||
f64::from(stats.max_fee_rate()),
|
||||
total_fee_btc,
|
||||
stats.tx_count,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Address tracking stats
|
||||
let entries = mempool.entries();
|
||||
let txs = mempool.txs();
|
||||
let addrs = mempool.addrs();
|
||||
println!("\n=== Address Tracking ===");
|
||||
println!(" Addresses with pending txs: {}", addrs.len());
|
||||
let graveyard = mempool.graveyard();
|
||||
let outpoint_spends = mempool.state().outpoint_spends.read();
|
||||
let snapshot = mempool.snapshot();
|
||||
|
||||
println!("\n----------------------------------------");
|
||||
let cluster_nodes_total: usize = snapshot.clusters.iter().map(|c| c.nodes.len()).sum();
|
||||
let blocks_tx_total: usize = snapshot.blocks.iter().map(|b| b.len()).sum();
|
||||
let (skip_clean, skip_throttled) = mempool.skip_counts();
|
||||
|
||||
println!(
|
||||
"info.count={} entries.slots={} entries.active={} entries.free={} \
|
||||
txs={} unresolved={} addrs={} outpoints={} \
|
||||
graveyard.tombstones={} graveyard.order={} \
|
||||
snap.clusters={} snap.cluster_nodes={} snap.cluster_of.len={} snap.cluster_of.active={} \
|
||||
snap.blocks={} snap.blocks_txs={} \
|
||||
rebuilds={} skip.clean={} skip.throttled={}",
|
||||
info.count,
|
||||
entries.entries().len(),
|
||||
entries.active_count(),
|
||||
entries.free_slots_count(),
|
||||
txs.len(),
|
||||
txs.unresolved().len(),
|
||||
addrs.len(),
|
||||
outpoint_spends.len(),
|
||||
graveyard.tombstones_len(),
|
||||
graveyard.order_len(),
|
||||
snapshot.clusters.len(),
|
||||
cluster_nodes_total,
|
||||
snapshot.cluster_of_len(),
|
||||
snapshot.cluster_of_active(),
|
||||
snapshot.blocks.len(),
|
||||
blocks_tx_total,
|
||||
mempool.rebuild_count(),
|
||||
skip_clean,
|
||||
skip_throttled,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user