diff --git a/accumulators/Cargo.toml b/accumulators/Cargo.toml index e252c7b1..7277dad1 100644 --- a/accumulators/Cargo.toml +++ b/accumulators/Cargo.toml @@ -22,8 +22,8 @@ path = '../crypto' [dependencies.storage] git = 'https://github.com/FindoraNetwork/storage.git' -tag = 'v0.2.1' +tag = 'v0.2.2' [dev-dependencies.mem_db] git = 'https://github.com/FindoraNetwork/storage.git' -tag = 'v0.2.1' +tag = 'v0.2.2' diff --git a/accumulators/src/merkle_tree.rs b/accumulators/src/merkle_tree.rs index 75ccce14..cca6341d 100644 --- a/accumulators/src/merkle_tree.rs +++ b/accumulators/src/merkle_tree.rs @@ -75,6 +75,13 @@ impl<'a, D: MerkleDB> PersistentMerkleTree<'a, D> { } else { store.set(&ROOT_KEY, BLSScalar::zero().zei_to_bytes())?; store.set(&ENTRY_COUNT_KEY, 0u64.to_be_bytes().to_vec())?; + + if !store.state_mut().cache_mut().good2_commit() { + store.state_mut().cache_mut().discard(); + + return Err(eg!("store commit no good")); + } + store.state_mut().commit(0).c(d!())?; } @@ -239,6 +246,13 @@ impl<'a, D: MerkleDB> PersistentMerkleTree<'a, D> { /// commit to store and add the tree version pub fn commit(&mut self) -> Result { let height = self.store.height()?; + + if !self.store.state_mut().cache_mut().good2_commit() { + self.store.state_mut().cache_mut().discard(); + + return Err(eg!("store commit no good")); + } + let (_, ver) = self.store.state_mut().commit(height + 1).c(d!())?; Ok(ver) } diff --git a/api/Cargo.toml b/api/Cargo.toml index f01dddea..dcddefbb 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -96,11 +96,11 @@ default-features = false [dev-dependencies.storage] git = 'https://github.com/FindoraNetwork/storage.git' -tag = 'v0.2.1' +tag = 'v0.2.2' [dev-dependencies.mem_db] git = 'https://github.com/FindoraNetwork/storage.git' -tag = 'v0.2.1' +tag = 'v0.2.2' [dependencies.ark-bulletproofs-secq256k1] git = "https://github.com/FindoraNetwork/ark-bulletproofs-secq256k1"