Reorder mempool polling and metrics serving

This commit is contained in:
Roman Zeyde 2018-06-13 11:45:07 +03:00
parent ead1e02f9b
commit b0b48f555c
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -19,10 +19,11 @@ use electrs::{app::App,
fn run_server(config: &Config) -> Result<()> {
let signal = Waiter::new();
let metrics = Metrics::new(config.monitoring_addr);
metrics.start();
let daemon = Daemon::new(config.network_type, &metrics)?;
let store = DBStore::open(&config.db_path, StoreOptions { bulk_import: true });
let index = Index::load(&store, &metrics);
metrics.start();
let mut tip = index.update(&store, &daemon, &signal)?;
store.compact_if_needed();
@ -32,6 +33,8 @@ fn run_server(config: &Config) -> Result<()> {
let app = App::new(store, index, daemon);
let query = Query::new(app.clone(), &metrics);
query.update_mempool()?; // poll once before starting RPC server
let rpc = RPC::start(config.rpc_addr, query.clone(), &metrics);
while let None = signal.wait(Duration::from_secs(5)) {
query.update_mempool()?;