From 04fafebfa6343ef491bd7507c26846b64ca5201e Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 31 Jan 2023 21:48:57 +0100 Subject: [PATCH] fixup! Throw error when params don't match with previous run --- beacon_node/store/src/hot_cold_store.rs | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 554ba6261..194ac2f01 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -221,32 +221,33 @@ impl HotColdDB, LevelDB> { } let blob_info = db.load_blob_info()?; - let (open_blobs_db, path) = match (&blob_info, blobs_db_path) { - (Some(blob_info), Some(path)) => { + let open_blobs_db = match (&blob_info, &blobs_db_path) { + (Some(blob_info), Some(_)) => { if blob_info.blobs_db { - (true, path) + true } else { return Err(HotColdDBError::BlobsPreviouslyInDefaultStore.into()); } } - (None, Some(path)) => (true, path), + (None, Some(_)) => true, (Some(_), None) => return Err(HotColdDBError::MissingPathToBlobsDatabase.into()), - (None, None) => (false, cold_path.to_path_buf()), + (None, None) => false, }; - let new_blob_info = if open_blobs_db { - db.blobs_db = Some(LevelDB::open(path.as_path())?); - Some(BlobInfo { blobs_db: true }) - } else { - Some(BlobInfo { blobs_db: false }) - }; - - db.compare_and_set_blob_info_with_write(blob_info, new_blob_info)?; - info!( - db.log, - "Blobs DB initialized"; - "path" => ?path - ); + if let Some(path) = blobs_db_path { + let new_blob_info = if open_blobs_db { + db.blobs_db = Some(LevelDB::open(path.as_path())?); + Some(BlobInfo { blobs_db: true }) + } else { + Some(BlobInfo { blobs_db: false }) + }; + db.compare_and_set_blob_info_with_write(blob_info, new_blob_info)?; + info!( + db.log, + "Blobs DB initialized"; + "path" => ?path + ); + } // Ensure that the schema version of the on-disk database matches the software. // If the version is mismatched, an automatic migration will be attempted.