mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 09:13:41 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user