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:
parent
610a0ade07
commit
79b182af08
1 changed files with 19 additions and 0 deletions
19
src/store.rs
19
src/store.rs
|
@ -142,3 +142,22 @@ impl Drop for DBStore {
|
||||||
trace!("closing DB at {:?}", self.opts.path);
|
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()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue