mirror of
https://github.com/romanz/electrs.git
synced 2025-02-24 23:08:39 +01:00
Re-introduce mempool vsize and txs' count metrics' -m Fixes
This commit is contained in:
parent
e4256a0d2f
commit
121a4bcc91
2 changed files with 10 additions and 3 deletions
|
@ -11,7 +11,7 @@ use bitcoincore_rpc::json;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use serde::ser::{Serialize, SerializeSeq, Serializer};
|
use serde::ser::{Serialize, SerializeSeq, Serializer};
|
||||||
|
|
||||||
use crate::{daemon::Daemon, types::ScriptHash};
|
use crate::{daemon::Daemon, types::ScriptHash, metrics::{Metrics, Gauge}};
|
||||||
|
|
||||||
pub(crate) struct Entry {
|
pub(crate) struct Entry {
|
||||||
pub txid: Txid,
|
pub txid: Txid,
|
||||||
|
@ -27,6 +27,9 @@ pub(crate) struct Mempool {
|
||||||
by_funding: BTreeSet<(ScriptHash, Txid)>,
|
by_funding: BTreeSet<(ScriptHash, Txid)>,
|
||||||
by_spending: BTreeSet<(OutPoint, Txid)>,
|
by_spending: BTreeSet<(OutPoint, Txid)>,
|
||||||
fees: FeeHistogram,
|
fees: FeeHistogram,
|
||||||
|
// stats
|
||||||
|
vsize: Gauge,
|
||||||
|
count: Gauge,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smallest possible txid
|
// Smallest possible txid
|
||||||
|
@ -40,12 +43,14 @@ fn txid_max() -> Txid {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mempool {
|
impl Mempool {
|
||||||
pub fn new() -> Self {
|
pub fn new(metrics: &Metrics) -> Self {
|
||||||
Self {
|
Self {
|
||||||
entries: Default::default(),
|
entries: Default::default(),
|
||||||
by_funding: Default::default(),
|
by_funding: Default::default(),
|
||||||
by_spending: Default::default(),
|
by_spending: Default::default(),
|
||||||
fees: FeeHistogram::empty(),
|
fees: FeeHistogram::empty(),
|
||||||
|
vsize: metrics.gauge("mempool_txs_vsize", "Total vsize of mempool transactions (in bytes)"),
|
||||||
|
count: metrics.gauge("mempool_txs_count", "Total number of mempool transactions"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +121,8 @@ impl Mempool {
|
||||||
self.add_entry(*txid, tx, entry);
|
self.add_entry(*txid, tx, entry);
|
||||||
}
|
}
|
||||||
self.fees = FeeHistogram::new(self.entries.values().map(|e| (e.fee, e.vsize)));
|
self.fees = FeeHistogram::new(self.entries.values().map(|e| (e.fee, e.vsize)));
|
||||||
|
self.vsize.set(self.entries.values().map(|e| e.vsize).sum::<u64>() as f64);
|
||||||
|
self.count.set(self.entries.values().len() as f64);
|
||||||
debug!(
|
debug!(
|
||||||
"{} mempool txs: {} added, {} removed",
|
"{} mempool txs: {} added, {} removed",
|
||||||
self.entries.len(),
|
self.entries.len(),
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Tracker {
|
||||||
config.reindex_last_blocks,
|
config.reindex_last_blocks,
|
||||||
)
|
)
|
||||||
.context("failed to open index")?,
|
.context("failed to open index")?,
|
||||||
mempool: Mempool::new(),
|
mempool: Mempool::new(&metrics),
|
||||||
metrics,
|
metrics,
|
||||||
ignore_mempool: config.ignore_mempool,
|
ignore_mempool: config.ignore_mempool,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue