1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Use regular indexing instead of the bulk-based one (with disabled compaction)

This commit is contained in:
Roman Zeyde 2018-08-05 15:01:18 +03:00
parent 972a155ce0
commit 0b4a56ade8
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
3 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,7 @@ impl App {
index: index::Index,
daemon: daemon::Daemon,
) -> Result<Arc<App>> {
index.reload(&store);
Ok(Arc::new(App {
store,
index,

View File

@ -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);

View File

@ -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<HeaderEntry> {
let headers = self.headers.read().unwrap();
headers.header_by_blockhash(headers.tip()).cloned()