1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-24 15:02:21 +01:00
electrs/examples/index.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

/// Benchmark regular indexing flow (using JSONRPC), don't persist the resulting index.
extern crate electrs;
extern crate error_chain;
2018-06-25 22:16:22 +03:00
#[macro_use]
extern crate log;
2018-07-03 11:46:36 +03:00
use electrs::{
cache::BlockTxIDsCache, config::Config, daemon::Daemon, errors::*, fake::FakeStore,
index::Index, metrics::Metrics, signal::Waiter,
2018-07-03 11:46:36 +03:00
};
2018-06-09 18:22:30 +03:00
use error_chain::ChainedError;
use std::sync::Arc;
fn run() -> Result<()> {
2019-03-08 18:37:24 +02:00
let signal = Waiter::start();
let config = Config::from_args();
let metrics = Metrics::new(config.monitoring_addr);
metrics.start();
2019-07-03 23:43:11 +02:00
let cache = Arc::new(BlockTxIDsCache::new(0, &metrics));
2018-07-09 17:10:24 +03:00
let daemon = Daemon::new(
&config.daemon_dir,
config.daemon_rpc_addr,
config.cookie_getter(),
2018-07-09 17:10:24 +03:00
config.network_type,
signal.clone(),
cache,
2018-07-09 17:10:24 +03:00
&metrics,
)?;
let fake_store = FakeStore {};
let index = Index::load(&fake_store, &daemon, &metrics, config.index_batch_size)?;
index.update(&fake_store, &signal)?;
Ok(())
}
fn main() {
if let Err(e) = run() {
2018-06-25 22:16:22 +03:00
error!("{}", e.display_chain());
}
}