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

45 lines
1.0 KiB
Rust
Raw Normal View History

/// Benchmark bulk indexing flow (using local blk*.dat files).
/// Persist (and compact) the resulting index
extern crate electrs;
#[macro_use]
extern crate log;
extern crate error_chain;
use electrs::{
bulk, config::Config, daemon::Daemon, errors::*, metrics::Metrics, signal::Waiter,
store::DBStore,
};
use error_chain::ChainedError;
fn run(config: Config) -> Result<()> {
if config.db_path.exists() {
panic!(
"DB {:?} must not exist when running this benchmark!",
config.db_path
);
}
let signal = Waiter::new();
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.daemon_rpc_addr,
config.cookie_getter(),
2018-07-09 16:10:24 +02:00
config.network_type,
signal,
2018-07-09 16:10:24 +02:00
&metrics,
)?;
let store = DBStore::open(&config.db_path);
2018-07-13 21:08:50 +02:00
bulk::index(&daemon, &metrics, store)?;
Ok(())
}
fn main() {
if let Err(e) = run(Config::from_args()) {
2018-06-25 21:16:22 +02:00
error!("{}", e.display_chain());
}
}