mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 18:10:51 +01:00
Monitor fee rates for next blocks' confirmation
This commit is contained in:
parent
3d77353d78
commit
46bda14ddf
@ -9,7 +9,7 @@ use std::sync::RwLock;
|
|||||||
|
|
||||||
use daemon::{Daemon, MempoolEntry};
|
use daemon::{Daemon, MempoolEntry};
|
||||||
use index::index_transaction;
|
use index::index_transaction;
|
||||||
use metrics::{Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
|
use metrics::{Gauge, GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
|
||||||
use store::{ReadStore, Row};
|
use store::{ReadStore, Row};
|
||||||
use util::Bytes;
|
use util::Bytes;
|
||||||
|
|
||||||
@ -100,6 +100,7 @@ struct Stats {
|
|||||||
count: Gauge,
|
count: Gauge,
|
||||||
vsize: Gauge,
|
vsize: Gauge,
|
||||||
update: HistogramVec,
|
update: HistogramVec,
|
||||||
|
fees: GaugeVec,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stats {
|
impl Stats {
|
||||||
@ -134,6 +135,10 @@ impl Tracker {
|
|||||||
HistogramOpts::new("mempool_update", "Time to update mempool (in seconds)"),
|
HistogramOpts::new("mempool_update", "Time to update mempool (in seconds)"),
|
||||||
&["step"],
|
&["step"],
|
||||||
),
|
),
|
||||||
|
fees: metrics.gauge_vec(
|
||||||
|
MetricOpts::new("mempool_fees", "Fee rate to get confirmation in N blocks"),
|
||||||
|
&["blocks"],
|
||||||
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,6 +227,23 @@ impl Tracker {
|
|||||||
e2.fee_per_vbyte().partial_cmp(&e1.fee_per_vbyte()).unwrap()
|
e2.fee_per_vbyte().partial_cmp(&e1.fee_per_vbyte()).unwrap()
|
||||||
});
|
});
|
||||||
self.histogram = electrum_fees(&entries);
|
self.histogram = electrum_fees(&entries);
|
||||||
|
self.report_fees(&entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn report_fees(&self, entries: &[&MempoolEntry]) {
|
||||||
|
let block_vsize = 1_000_000;
|
||||||
|
let mut blocks = 1;
|
||||||
|
let mut vsize = 0;
|
||||||
|
for e in entries {
|
||||||
|
vsize += e.vsize();
|
||||||
|
if vsize > blocks * block_vsize {
|
||||||
|
self.stats
|
||||||
|
.fees
|
||||||
|
.with_label_values(&[&blocks.to_string()])
|
||||||
|
.set(e.fee_per_vbyte() as f64);
|
||||||
|
blocks += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user