Unverified Commit 1a117933 authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Remove mempool logging to be replaced by proper monitoring

parent 2facecb9
......@@ -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()?;
......
......@@ -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(())
}
......
......@@ -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(),
})
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment