From 1a117933ffb336792fefd2d1d6072a9290f1f8c4 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 12 Jun 2018 23:41:10 +0300 Subject: [PATCH] Remove mempool logging to be replaced by proper monitoring --- src/bin/main.rs | 2 +- src/mempool.rs | 15 +++------------ src/query.rs | 5 +++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index c71df4e..bb62c0c 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -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()?; diff --git a/src/mempool.rs b/src/mempool.rs index d3d652c..c47d5b0 100644 --- a/src/mempool.rs +++ b/src/mempool.rs @@ -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(()) } diff --git a/src/query.rs b/src/query.rs index 416ae44..3a20170 100644 --- a/src/query.rs +++ b/src/query.rs @@ -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) -> Arc { + pub fn new(app: Arc, metrics: &Metrics) -> Arc { Arc::new(Query { app, - tracker: RwLock::new(Tracker::new()), + tracker: RwLock::new(Tracker::new(metrics)), tx_cache: TransactionCache::new(), }) }