1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00
electrs/examples/bench_parse.rs
2018-07-03 11:46:36 +03:00

34 lines
815 B
Rust

extern crate bitcoin;
extern crate electrs;
#[macro_use]
extern crate log;
extern crate error_chain;
use electrs::{
bulk::Parser, config::Config, daemon::Daemon, errors::*, metrics::Metrics,
store::{DBStore, StoreOptions, WriteStore},
};
use error_chain::ChainedError;
fn run(config: Config) -> Result<()> {
let metrics = Metrics::new(config.monitoring_addr);
metrics.start();
let daemon = Daemon::new(&config.daemon_dir, config.network_type, &metrics)?;
let store = DBStore::open("./test-db", StoreOptions { bulk_import: true });
let parser = Parser::new(&daemon, &store, &metrics)?;
for rows in parser.start().iter() {
store.write(rows?);
}
Ok(())
}
fn main() {
if let Err(e) = run(Config::from_args()) {
error!("{}", e.display_chain());
}
}