Skip to content

Commit 56083e5

Browse files
committed
Change kv_store::delete to remove
Rust HashMap has remove function that returns Option. I changed kv_store::delete function to make consistent with other code.
1 parent 454e843 commit 56083e5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/src/ibc/context.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ impl<'a> KVStore for TopLevelKVStore<'a> {
8585
self.state.update_ibc_data(&key, value.to_vec()).expect("Set in IBC KVStore").map(Bytes::from)
8686
}
8787

88-
fn delete(&mut self, path: Path) {
88+
fn remove(&mut self, path: Path) -> Option<Bytes> {
89+
let prev = self.get(path);
8990
let key = TopLevelKVStore::key(path);
9091
self.state.remove_ibc_data(&key);
92+
prev
9193
}
9294

9395
fn root(&self) -> H256 {

core/src/ibc/kv_store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub trait KVStore {
2424
fn get(&self, path: Path) -> Option<Bytes>;
2525
fn contains_key(&self, path: Path) -> bool;
2626
fn insert(&mut self, path: Path, value: &[u8]) -> Option<Bytes>;
27-
fn delete(&mut self, path: Path);
27+
fn remove(&mut self, path: Path) -> Option<Bytes>;
2828
fn root(&self) -> H256;
2929
fn make_proof(&self, path: Path) -> (CryptoProofUnit, CryptoProof);
3030
}

0 commit comments

Comments
 (0)