Improve syntax

This commit is contained in:
Emilia Hane 2023-01-11 13:38:43 +01:00
parent 3c0aa201e3
commit 3679a0f1cb
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA
2 changed files with 16 additions and 20 deletions

View File

@ -168,10 +168,9 @@ impl Config {
/// Get the blobs freezer DB path, creating it if necessary.
pub fn create_blobs_freezer_db_path(&self) -> Result<Option<PathBuf>, String> {
if let Some(blobs_freezer_path) = self.get_blobs_freezer_db_path() {
Ok(Some(ensure_dir_exists(blobs_freezer_path)?))
} else {
Ok(None)
match self.get_blobs_freezer_db_path() {
Some(blobs_freezer_path) => Ok(Some(ensure_dir_exists(blobs_freezer_path)?)),
None => Ok(None),
}
}

View File

@ -1250,15 +1250,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
pub fn load_hot_blobs(&self, block_root: &Hash256) -> Result<Option<BlobsSidecar<E>>, Error> {
// FIXME(sean) I was attempting to use a blob cache here but was getting deadlocks,
// may want to attempt to use one again
if let Some(bytes) = self
match self
.hot_db
.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?
{
let ret = BlobsSidecar::from_ssz_bytes(&bytes)?;
self.blob_cache.lock().put(*block_root, ret.clone());
Ok(Some(ret))
} else {
Ok(None)
Some(bytes) => {
let ret = BlobsSidecar::from_ssz_bytes(&bytes)?;
self.blob_cache.lock().put(*block_root, ret.clone());
Ok(Some(ret))
}
None => Ok(None),
}
}
@ -1272,12 +1273,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
&self.cold_db
};
if let Some(ref blobs_bytes) =
blobs_freezer.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?
{
Ok(Some(BlobsSidecar::from_ssz_bytes(blobs_bytes)?))
} else {
Ok(None)
match blobs_freezer.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())? {
Some(ref blobs_bytes) => Ok(Some(BlobsSidecar::from_ssz_bytes(blobs_bytes)?)),
None => Ok(None),
}
}
@ -1989,10 +1987,9 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
let mut hot_db_ops: Vec<StoreOp<E>> = Vec::new();
let mut cold_blobs_db_ops: Vec<StoreOp<E>> = Vec::new();
let blobs_freezer = if let Some(ref cold_blobs_db) = store.cold_blobs_db {
cold_blobs_db
} else {
&store.cold_db
let blobs_freezer = match store.cold_blobs_db {
Some(ref cold_blobs_db) => cold_blobs_db,
None => &store.cold_db,
};
// 1. Copy all of the states between the head and the split slot, from the hot DB