2018-06-23 15:17:04 +02:00
|
|
|
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},
|
|
|
|
};
|
2018-06-23 15:17:04 +02:00
|
|
|
|
|
|
|
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 });
|
2018-06-23 15:17:04 +02:00
|
|
|
|
2018-06-28 12:39:43 +02:00
|
|
|
let parser = Parser::new(&daemon, &store, &metrics)?;
|
2018-06-28 22:08:18 +02:00
|
|
|
for rows in parser.start().iter() {
|
|
|
|
store.write(rows?);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|