mirror of
https://github.com/romanz/electrs.git
synced 2025-02-23 14:50:45 +01:00
Persist last indexed block marker
This commit is contained in:
parent
6609d6e008
commit
dd70a1cc8a
2 changed files with 13 additions and 1 deletions
|
@ -87,7 +87,9 @@ fn run(config: Config) -> Result<()> {
|
|||
.expect("indexer panicked")
|
||||
.expect("indexing failed")
|
||||
});
|
||||
store.compact();
|
||||
store.write(vec![parser.last_indexed_row()]);
|
||||
store.flush();
|
||||
store.compact(); // will take a while.
|
||||
}).join()
|
||||
.expect("writer panicked");
|
||||
Ok(())
|
||||
|
|
10
src/bulk.rs
10
src/bulk.rs
|
@ -51,6 +51,16 @@ impl Parser {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn last_indexed_row(&self) -> Row {
|
||||
let indexed_blockhashes = self.indexed_blockhashes.lock().unwrap();
|
||||
let last_header = self.current_headers
|
||||
.iter()
|
||||
.take_while(|h| indexed_blockhashes.contains(h.hash()))
|
||||
.last()
|
||||
.expect("no indexed header found");
|
||||
last_indexed_block(last_header.hash())
|
||||
}
|
||||
|
||||
pub fn read_blkfile(&self, path: &Path) -> Result<Vec<u8>> {
|
||||
let timer = self.duration.with_label_values(&["read"]).start_timer();
|
||||
let blob = fs::read(&path).chain_err(|| format!("failed to read {:?}", path))?;
|
||||
|
|
Loading…
Add table
Reference in a new issue