Add append api and use it to deposit events (#5795)

* use append api to deposit events

* use optimized append

* one more optimization

* fix bug

* fix issues

* address review
This commit is contained in:
Nikolay Volf
2020-04-27 19:06:59 +03:00
committed by GitHub
parent 9e4901f3d5
commit 33d00692d8
8 changed files with 123 additions and 13 deletions
@@ -223,6 +223,13 @@ impl OverlayedChanges {
})
}
/// Returns mutable reference to either commited or propsective value.
pub fn value_mut(&mut self, key: &[u8]) -> Option<&mut Option<StorageValue>> {
// not using map because of double borrow inside closure
if let Some(entry) = self.prospective.top.get_mut(key) { return Some(&mut entry.value) }
return self.committed.top.get_mut(key).map(|entry| &mut entry.value);
}
/// Returns a double-Option: None if the key is unknown (i.e. and the query should be referred
/// to the backend); Some(None) if the key has been deleted. Some(Some(...)) for a key whose
/// value has been set.