1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-22 22:36:37 +01:00

Don't flush when nothing is written to DB

Fixes #680.
This commit is contained in:
Roman Zeyde 2023-11-22 21:45:18 +02:00
parent 87752803ae
commit 4af15e90be
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB
2 changed files with 8 additions and 1 deletions

View file

@ -281,6 +281,7 @@ impl DBStore {
}
pub(crate) fn flush(&self) {
debug!("flushing DB column families");
let mut config = self.get_config().unwrap_or_default();
for name in COLUMN_FAMILIES {
let cf = self.db.cf_handle(name).expect("missing CF");

View file

@ -86,6 +86,7 @@ pub struct Index {
chain: Chain,
stats: Stats,
is_ready: bool,
flush_needed: bool,
}
impl Index {
@ -117,6 +118,7 @@ impl Index {
chain,
stats,
is_ready: false,
flush_needed: false,
})
}
@ -179,7 +181,10 @@ impl Index {
);
}
_ => {
self.store.flush(); // full compaction is performed on the first flush call
if self.flush_needed {
self.store.flush(); // full compaction is performed on the first flush call
self.flush_needed = false;
}
self.is_ready = true;
return Ok(true); // no more blocks to index (done for now)
}
@ -195,6 +200,7 @@ impl Index {
}
self.chain.update(new_headers);
self.stats.observe_chain(&self.chain);
self.flush_needed = true;
Ok(false) // sync is not done
}