mirror of
https://github.com/vacp2p/zerokit.git
synced 2026-01-09 14:38:01 -05:00
feat(rln): close db connection before dropping rln object (#187)
This commit is contained in:
committed by
GitHub
parent
c6b7a8c0a4
commit
23d2331b78
@@ -101,6 +101,10 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn close_db_connection(&mut self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Returns the depth of the tree
|
||||
fn depth(&self) -> usize {
|
||||
self.depth
|
||||
|
||||
@@ -65,6 +65,7 @@ pub trait ZerokitMerkleTree {
|
||||
fn verify(&self, leaf: &FrOf<Self::Hasher>, witness: &Self::Proof) -> Result<bool>;
|
||||
fn set_metadata(&mut self, metadata: &[u8]) -> Result<()>;
|
||||
fn metadata(&self) -> Result<Vec<u8>>;
|
||||
fn close_db_connection(&mut self) -> Result<()>;
|
||||
}
|
||||
|
||||
pub trait ZerokitMerkleProof {
|
||||
|
||||
@@ -83,6 +83,10 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn close_db_connection(&mut self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Returns the depth of the tree
|
||||
fn depth(&self) -> usize {
|
||||
self.depth
|
||||
|
||||
@@ -45,6 +45,15 @@ impl Database for SledDB {
|
||||
Ok(SledDB(db))
|
||||
}
|
||||
|
||||
fn close(&mut self) -> PmtreeResult<()> {
|
||||
let _ = self.0.flush().map_err(|_| {
|
||||
PmtreeErrorKind::DatabaseError(DatabaseErrorKind::CustomError(
|
||||
"Cannot flush database".to_string(),
|
||||
))
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get(&self, key: DBKey) -> PmtreeResult<Option<Value>> {
|
||||
match self.0.get(key) {
|
||||
Ok(value) => Ok(value.map(|val| val.to_vec())),
|
||||
|
||||
Reference in New Issue
Block a user