feat(rolldb): add method to check if db is empty (#352)

This commit is contained in:
Santiago Carmuega 2023-12-11 14:06:01 -03:00 committed by GitHub
parent 049f424581
commit 472692c4fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -265,6 +265,10 @@ impl Store {
Ok(false)
}
pub fn is_empty(&self) -> bool {
HashBySlotKV::is_empty(&self.db) && BlockByHashKV::is_empty(&self.db)
}
pub fn destroy(path: impl AsRef<Path>) -> Result<(), Error> {
DB::destroy(&Options::default(), path).map_err(|_| Error::IO)
}

View file

@ -355,6 +355,10 @@ impl Store {
Ok(())
}
pub fn is_empty(&self) -> bool {
WalKV::is_empty(&self.db)
}
pub fn destroy(path: impl AsRef<Path>) -> Result<(), Error> {
DB::destroy(&Options::default(), path).map_err(|_| Error::IO)
}