From 46a39a373ffdb6da14fd122b008437e63f1f7e2b Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Mon, 24 Jul 2023 15:56:12 +0530 Subject: [PATCH] chore: add close db connection feature --- src/database.rs | 3 +++ src/tree.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/database.rs b/src/database.rs index 9510f61..55f7989 100644 --- a/src/database.rs +++ b/src/database.rs @@ -25,4 +25,7 @@ pub trait Database { /// Puts the leaves batch to the db fn put_batch(&mut self, subtree: HashMap) -> PmtreeResult<()>; + + /// Closes the db connection + fn close(&mut self) -> PmtreeResult<()>; } diff --git a/src/tree.rs b/src/tree.rs index 7272945..88b6df8 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -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() {