1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00
electrs/examples/bench_parse.rs

41 lines
903 B
Rust
Raw Normal View History

extern crate bitcoin;
extern crate electrs;
#[macro_use]
extern crate log;
extern crate error_chain;
2018-07-06 09:38:03 +02:00
use std::path::Path;
2018-07-03 10:46:36 +02:00
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();
2018-07-09 16:10:24 +02:00
let daemon = Daemon::new(
&config.daemon_dir,
&config.cookie,
config.network_type,
&metrics,
)?;
2018-07-06 09:38:03 +02:00
let store = DBStore::open(Path::new("./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()) {
2018-06-25 21:16:22 +02:00
error!("{}", e.display_chain());
}
}