Skip to content

Commit

Permalink
update storage version (#127)
Browse files Browse the repository at this point in the history
Co-authored-by: harry <harry@findora.org>
  • Loading branch information
HarryLiIsMe and harryliisme3 authored Aug 15, 2022
1 parent 6bc02f0 commit 48b4177
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions accumulators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
14 changes: 14 additions & 0 deletions accumulators/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!())?;
}

Expand Down Expand Up @@ -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<u64> {
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)
}
Expand Down
4 changes: 2 additions & 2 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 48b4177

Please sign in to comment.