Skip to content

Commit

Permalink
fix: apply trie log backwards, and match rocksdb version with madara
Browse files Browse the repository at this point in the history
  • Loading branch information
cchudant committed Nov 25, 2024
1 parent a74f1ae commit 03c47e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ starknet-types-core = { version = "0.1.7", default-features = false, features =
] }

# Optionals
rocksdb = { optional = true, version = "0.21.0", features = [
rocksdb = { optional = true, version = "0.22", features = [
"multi-threaded-cf",
] }

Expand Down
13 changes: 7 additions & 6 deletions src/key_value_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,18 @@ where
))
})?,
);
// Apply backwards
for (key, change) in changes.0 {
let key = DatabaseKey::from(&key);
match (&change.old_value, &change.new_value) {
(Some(_), Some(new_value)) => {
txn.insert(&key, new_value, Some(&mut batch))?;
(Some(old_value), Some(_)) => {
txn.insert(&key, old_value, Some(&mut batch))?;
}
(Some(_), None) => {
txn.remove(&key, Some(&mut batch))?;
(Some(old_value), None) => {
txn.insert(&key, old_value, Some(&mut batch))?;
}
(None, Some(new_value)) => {
txn.insert(&key, new_value, Some(&mut batch))?;
(None, Some(_)) => {
txn.remove(&key, Some(&mut batch))?;
}
(None, None) => unreachable!(),
};
Expand Down

0 comments on commit 03c47e5

Please sign in to comment.