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

Add simple binary for testing mempool tracker

This commit is contained in:
Roman Zeyde 2018-05-16 21:56:21 +03:00
parent 7bf1c562b2
commit f56125eb11
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

30
src/bin/tracker.rs Normal file
View File

@ -0,0 +1,30 @@
extern crate indexrs;
extern crate simplelog;
#[macro_use]
extern crate log;
use indexrs::{daemon, mempool};
use std::thread;
use std::time::{Duration, Instant};
fn main() {
use simplelog::*;
let mut cfg = Config::default();
cfg.time_format = Some("%F %H:%M:%S%.3f");
CombinedLogger::init(vec![
TermLogger::new(LevelFilter::Debug, cfg.clone()).unwrap(),
]).unwrap();
let daemon = daemon::Daemon::new("localhost:8332");
let mut tracker = mempool::Tracker::new(&daemon);
loop {
let t = Instant::now();
tracker.update_from_daemon().unwrap();
let dt = t.elapsed();
info!(
"update took {:.3} ms",
(dt.as_secs() as f64 + 1e-9f64 * dt.subsec_nanos() as f64) * 1e3
);
thread::sleep(Duration::from_secs(1));
}
}