mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-10 13:01:22 +00:00
fixup! Store blobs in correct db for atomic ops
This commit is contained in:
parent
dcb5495745
commit
22915c2d7e
@ -890,30 +890,39 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(blob_ops) = blobs_batch {
|
let guard_blob = match blobs_batch {
|
||||||
let blobs_db = self.blobs_db.as_ref().unwrap_or(&self.cold_db);
|
Some(blob_ops) => {
|
||||||
let mut guard_blob = self.blob_cache.lock();
|
let blobs_db = self.blobs_db.as_ref().unwrap_or(&self.cold_db);
|
||||||
|
// Update the blob cache whilst holding a lock, while holding a lock on the block
|
||||||
|
// cache, to ensure they and their databases all update atomically.
|
||||||
|
let mut guard_blob = self.blob_cache.lock();
|
||||||
|
|
||||||
for op in &blob_ops {
|
for op in &blob_ops {
|
||||||
match op {
|
match op {
|
||||||
StoreOp::PutBlobs(block_root, blobs) => {
|
StoreOp::PutBlobs(block_root, blobs) => {
|
||||||
guard_blob.put(*block_root, (**blobs).clone());
|
guard_blob.put(*block_root, (**blobs).clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
StoreOp::DeleteBlobs(block_root) => {
|
||||||
|
guard_blob.pop(block_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreOp::DeleteBlobs(block_root) => {
|
|
||||||
guard_blob.pop(block_root);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
blobs_db.do_atomically(self.convert_to_kv_batch(blob_ops)?)?;
|
||||||
|
Some(guard_blob)
|
||||||
}
|
}
|
||||||
blobs_db.do_atomically(self.convert_to_kv_batch(blob_ops)?)?;
|
None => None,
|
||||||
drop(guard_blob);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
self.hot_db
|
self.hot_db
|
||||||
.do_atomically(self.convert_to_kv_batch(batch)?)?;
|
.do_atomically(self.convert_to_kv_batch(batch)?)?;
|
||||||
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
if let Some(guard_blob) = guard_blob {
|
||||||
|
drop(guard_blob);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user