Write new blocks and states to the database atomically (#1285)

* Mostly atomic put_state()
* Reduce number of vec allocations
* Make crucial db operations atomic
* Save restore points
* Remove StateBatch
* Merge two HotColdDB impls
* Further reduce allocations
* Review feedback
* Silence clippy warning
This commit is contained in:
Adam Szkoda
2020-07-01 04:45:57 +02:00
committed by GitHub
parent ac89bb190a
commit 536728b975
11 changed files with 189 additions and 184 deletions

View File

@@ -64,11 +64,15 @@ impl<E: EthSpec> KeyValueStore<E> for MemoryStore<E> {
Ok(())
}
fn do_atomically(&self, batch: &[KeyValueStoreOp]) -> Result<(), Error> {
fn do_atomically(&self, batch: Vec<KeyValueStoreOp>) -> Result<(), Error> {
for op in batch {
match op {
KeyValueStoreOp::PutKeyValue(key, value) => {
self.db.write().insert(key, value);
}
KeyValueStoreOp::DeleteKey(hash) => {
self.db.write().remove(hash);
self.db.write().remove(&hash);
}
}
}