2018-08-01 14:00:18 +02:00
|
|
|
/// Benchmark bulk indexing flow (using local blk*.dat files).
|
|
|
|
/// Persist (and compact) the resulting index
|
2018-06-23 15:17:04 +02:00
|
|
|
extern crate electrs;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2018-07-10 14:37:56 +02:00
|
|
|
|
2018-06-23 15:17:04 +02:00
|
|
|
extern crate error_chain;
|
|
|
|
|
2018-07-29 08:42:58 +02:00
|
|
|
use electrs::{
|
|
|
|
bulk, config::Config, daemon::Daemon, errors::*, metrics::Metrics, signal::Waiter,
|
|
|
|
store::DBStore,
|
|
|
|
};
|
2018-06-23 15:17:04 +02:00
|
|
|
|
|
|
|
use error_chain::ChainedError;
|
|
|
|
|
|
|
|
fn run(config: Config) -> Result<()> {
|
2018-07-11 20:25:27 +02:00
|
|
|
if config.db_path.exists() {
|
|
|
|
panic!(
|
|
|
|
"DB {:?} must not exist when running this benchmark!",
|
|
|
|
config.db_path
|
|
|
|
);
|
|
|
|
}
|
2018-07-29 08:42:58 +02:00
|
|
|
let signal = Waiter::new();
|
2018-06-23 15:17:04 +02:00
|
|
|
let metrics = Metrics::new(config.monitoring_addr);
|
|
|
|
metrics.start();
|
2018-07-09 16:10:24 +02:00
|
|
|
let daemon = Daemon::new(
|
|
|
|
&config.daemon_dir,
|
2018-07-15 21:39:19 +02:00
|
|
|
config.daemon_rpc_addr,
|
2018-07-28 10:29:19 +02:00
|
|
|
config.cookie_getter(),
|
2018-07-09 16:10:24 +02:00
|
|
|
config.network_type,
|
2018-07-29 08:42:58 +02:00
|
|
|
signal,
|
2018-07-09 16:10:24 +02:00
|
|
|
&metrics,
|
|
|
|
)?;
|
2018-07-13 11:34:22 +02:00
|
|
|
let store = DBStore::open(&config.db_path);
|
2018-07-13 21:08:50 +02:00
|
|
|
bulk::index(&daemon, &metrics, store)?;
|
|
|
|
Ok(())
|
2018-06-23 15:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if let Err(e) = run(Config::from_args()) {
|
2018-06-25 21:16:22 +02:00
|
|
|
error!("{}", e.display_chain());
|
2018-06-23 15:17:04 +02:00
|
|
|
}
|
|
|
|
}
|