blockstream-electrs/src/bin/bench_index.rs

46 lines
1.0 KiB
Rust
Raw Normal View History

extern crate electrs;
extern crate error_chain;
use electrs::{config::Config,
daemon::Daemon,
errors::*,
index::Index,
metrics::Metrics,
2018-06-11 18:46:14 +00:00
signal::Waiter,
store::{ReadStore, Row, WriteStore},
util::Bytes};
2018-06-09 15:22:30 +00:00
use error_chain::ChainedError;
struct FakeStore;
impl ReadStore for FakeStore {
fn get(&self, _key: &[u8]) -> Option<Bytes> {
None
}
fn scan(&self, _prefix: &[u8]) -> Vec<Row> {
vec![]
}
}
impl WriteStore for FakeStore {
fn write(&self, _rows: Vec<Row>) {}
2018-06-10 05:51:07 +00:00
fn flush(&self) {}
}
fn run() -> Result<()> {
let signal = Waiter::new();
let config = Config::from_args();
let metrics = Metrics::new(config.monitoring_addr);
let daemon = Daemon::new(config.network_type)?;
let fake_store = FakeStore {};
let index = Index::load(&fake_store, &metrics);
index.update(&fake_store, &daemon, &signal)?;
Ok(())
}
fn main() {
if let Err(e) = run() {
2018-06-09 15:22:30 +00:00
eprintln!("{}", e.display_chain());
}
}