1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Remove mempool logging to be replaced by proper monitoring

This commit is contained in:
Roman Zeyde 2018-06-12 23:41:10 +03:00
parent 2facecb95b
commit 1a117933ff
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
3 changed files with 7 additions and 15 deletions

View File

@ -37,7 +37,7 @@ fn run_server(config: &Config) -> Result<()> {
let store = DBStore::open(&config.db_path, StoreOptions { auto_compact: true });
let app = App::new(store, index, daemon);
let query = Query::new(app.clone());
let query = Query::new(app.clone(), &metrics);
let rpc = RPC::start(config.rpc_addr, query.clone());
while let None = signal.wait(Duration::from_secs(5)) {
query.update_mempool()?;

View File

@ -9,8 +9,9 @@ use std::sync::RwLock;
use daemon::{Daemon, MempoolEntry};
use index::index_transaction;
use metrics::Metrics;
use store::{ReadStore, Row};
use util::{Bytes, Timer};
use util::Bytes;
use errors::*;
@ -102,7 +103,7 @@ pub struct Tracker {
}
impl Tracker {
pub fn new() -> Tracker {
pub fn new(metrics: &Metrics) -> Tracker {
Tracker {
stats: HashMap::new(),
index: MempoolStore::new(),
@ -126,12 +127,10 @@ impl Tracker {
}
pub fn update(&mut self, daemon: &Daemon) -> Result<()> {
let mut metric = Timer::new();
let new_txids = daemon
.getmempooltxids()
.chain_err(|| "failed to update mempool from daemon")?;
let old_txids = HashSet::from_iter(self.stats.keys().cloned());
metric.tick("fetch");
for txid in new_txids.difference(&old_txids) {
let entry = match daemon.getmempoolentry(txid) {
Ok(entry) => entry,
@ -153,19 +152,11 @@ impl Tracker {
for txid in old_txids.difference(&new_txids) {
self.remove(txid);
}
metric.tick("index");
self.update_fee_histogram();
metric.tick("fees");
let vsize: u64 = self.stats
.values()
.map(|stat| stat.entry.vsize() as u64)
.sum();
debug!(
"mempool update ({} txns, {:.3} vMB) {:?}",
self.stats.len(),
vsize as f32 / 1e6,
metric
);
Ok(())
}

View File

@ -10,6 +10,7 @@ use std::sync::{Arc, RwLock};
use app::App;
use index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
use mempool::Tracker;
use metrics::Metrics;
use store::{ReadStore, Row};
use util::{FullHash, HashPrefix, HeaderEntry};
@ -163,10 +164,10 @@ pub struct Query {
}
impl Query {
pub fn new(app: Arc<App>) -> Arc<Query> {
pub fn new(app: Arc<App>, metrics: &Metrics) -> Arc<Query> {
Arc::new(Query {
app,
tracker: RwLock::new(Tracker::new()),
tracker: RwLock::new(Tracker::new(metrics)),
tx_cache: TransactionCache::new(),
})
}