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

Add full compaction helpers to store module

This commit is contained in:
Roman Zeyde 2018-08-31 20:49:27 +03:00
parent 610a0ade07
commit 79b182af08
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB

View file

@ -142,3 +142,22 @@ impl Drop for DBStore {
trace!("closing DB at {:?}", self.opts.path);
}
}
fn full_compaction_marker() -> Row {
Row {
key: b"F".to_vec(),
value: b"".to_vec(),
}
}
pub fn full_compaction(store: DBStore) -> DBStore {
store.flush();
let store = store.compact().enable_compaction();
store.write(vec![full_compaction_marker()]);
store
}
pub fn is_fully_compacted(store: &ReadStore) -> bool {
let marker = store.get(&full_compaction_marker().key);
marker.is_some()
}