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:
parent
7bf1c562b2
commit
f56125eb11
30
src/bin/tracker.rs
Normal file
30
src/bin/tracker.rs
Normal 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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user