chore: add close db connection feature

This commit is contained in:
rymnc 2023-07-24 15:56:12 +05:30
parent 8b005bb44a
commit 46a39a373f
No known key found for this signature in database
GPG Key ID: AAA088D5C68ECD34
2 changed files with 8 additions and 0 deletions

View File

@ -25,4 +25,7 @@ pub trait Database {
/// Puts the leaves batch to the db
fn put_batch(&mut self, subtree: HashMap<DBKey, Value>) -> PmtreeResult<()>;
/// Closes the db connection
fn close(&mut self) -> PmtreeResult<()>;
}

View File

@ -115,6 +115,11 @@ where
})
}
/// Closes the db connection
pub fn close(&mut self) -> PmtreeResult<()> {
self.db.close()
}
/// Sets a leaf at the specified tree index
pub fn set(&mut self, key: usize, leaf: H::Fr) -> PmtreeResult<()> {
if key >= self.capacity() {