diff --git a/Cargo.toml b/Cargo.toml index c449603..596679a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", ] } diff --git a/src/key_value_db.rs b/src/key_value_db.rs index be09664..29553ef 100644 --- a/src/key_value_db.rs +++ b/src/key_value_db.rs @@ -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!(), };