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 e54b493f5d
commit ffcd70c57a
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)
}