From 0b4a56ade80978658d4f82dcb46c651fe0dfb335 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sun, 5 Aug 2018 15:01:18 +0300 Subject: [PATCH] Use regular indexing instead of the bulk-based one (with disabled compaction) --- src/app.rs | 1 + src/bin/electrs.rs | 4 +++- src/index.rs | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index ebad040..6cce980 100644 --- a/src/app.rs +++ b/src/app.rs @@ -18,6 +18,7 @@ impl App { index: index::Index, daemon: daemon::Daemon, ) -> Result> { + index.reload(&store); Ok(Arc::new(App { store, index, diff --git a/src/bin/electrs.rs b/src/bin/electrs.rs index a13a184..3d840cb 100644 --- a/src/bin/electrs.rs +++ b/src/bin/electrs.rs @@ -28,12 +28,14 @@ fn run_server(config: &Config) -> Result<()> { )?; // Perform initial indexing from local blk*.dat block files. let store = DBStore::open(&config.db_path); + let index = Index::load(&store, &daemon, &metrics)?; let store = if config.skip_bulk_import { + index.update(&store, &signal)?; bulk::skip(store) } else { bulk::index(&daemon, &metrics, store) }?; - let index = Index::load(&store, &daemon, &metrics)?; + let app = App::new(store, index, daemon)?; let query = Query::new(app.clone(), &metrics); diff --git a/src/index.rs b/src/index.rs index b195ce5..5262cb0 100644 --- a/src/index.rs +++ b/src/index.rs @@ -318,6 +318,11 @@ impl Index { }) } + pub fn reload(&self, store: &ReadStore) { + let mut headers = self.headers.write().unwrap(); + *headers = read_indexed_headers(store); + } + pub fn best_header(&self) -> Option { let headers = self.headers.read().unwrap(); headers.header_by_blockhash(headers.tip()).cloned()