fixup! Help user choose blobs db
This commit is contained in:
parent
1300fb7ffa
commit
12720f9ac5
@ -221,38 +221,52 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open separate blobs directory if configured and same configuration was used on previous
|
||||||
|
// run.
|
||||||
let blob_info = db.load_blob_info()?;
|
let blob_info = db.load_blob_info()?;
|
||||||
let open_blobs_db = match (&blob_info, &blobs_db_path) {
|
let new_blob_info = {
|
||||||
(Some(blob_info), Some(_)) => {
|
match (&blob_info, &blobs_db_path) {
|
||||||
if blob_info.blobs_db {
|
(Some(blob_info), Some(_)) => {
|
||||||
true
|
if !blob_info.blobs_db {
|
||||||
} else {
|
return Err(HotColdDBError::BlobsPreviouslyInDefaultStore.into());
|
||||||
return Err(HotColdDBError::BlobsPreviouslyInDefaultStore.into());
|
}
|
||||||
|
BlobInfo {
|
||||||
|
oldest_blob_slot: blob_info.oldest_blob_slot,
|
||||||
|
blobs_db: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
(Some(blob_info), None) => {
|
||||||
|
if blob_info.blobs_db {
|
||||||
|
return Err(HotColdDBError::MissingPathToBlobsDatabase.into());
|
||||||
|
}
|
||||||
|
BlobInfo {
|
||||||
|
oldest_blob_slot: blob_info.oldest_blob_slot,
|
||||||
|
blobs_db: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(None, Some(_)) => BlobInfo {
|
||||||
|
oldest_blob_slot: None,
|
||||||
|
blobs_db: true,
|
||||||
|
}, // first time starting up node
|
||||||
|
(None, None) => BlobInfo {
|
||||||
|
oldest_blob_slot: None,
|
||||||
|
blobs_db: false,
|
||||||
|
}, // first time starting up node
|
||||||
}
|
}
|
||||||
(None, Some(_)) => true,
|
|
||||||
(Some(_), None) => return Err(HotColdDBError::MissingPathToBlobsDatabase.into()),
|
|
||||||
(None, None) => false,
|
|
||||||
};
|
};
|
||||||
|
if new_blob_info.blobs_db {
|
||||||
if let Some(path) = blobs_db_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())?);
|
db.blobs_db = Some(LevelDB::open(path.as_path())?);
|
||||||
let mut new_blob_info = blob_info.clone().unwrap_or_default();
|
}
|
||||||
new_blob_info.blobs_db = true;
|
|
||||||
new_blob_info
|
|
||||||
} else {
|
|
||||||
let mut new_blob_info = blob_info.clone().unwrap_or_default();
|
|
||||||
new_blob_info.blobs_db = false;
|
|
||||||
new_blob_info
|
|
||||||
};
|
|
||||||
db.compare_and_set_blob_info_with_write(blob_info, Some(new_blob_info))?;
|
|
||||||
info!(
|
|
||||||
db.log,
|
|
||||||
"Blobs DB initialized";
|
|
||||||
"path" => ?path
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
let blob_info = blob_info.unwrap_or(db.get_blob_info());
|
||||||
|
db.compare_and_set_blob_info_with_write(blob_info, new_blob_info)?;
|
||||||
|
info!(
|
||||||
|
db.log,
|
||||||
|
"Blobs DB initialized";
|
||||||
|
"use separate blobs db" => db.get_blob_info().blobs_db,
|
||||||
|
"path" => ?blobs_db_path
|
||||||
|
);
|
||||||
|
|
||||||
// Ensure that the schema version of the on-disk database matches the software.
|
// Ensure that the schema version of the on-disk database matches the software.
|
||||||
// If the version is mismatched, an automatic migration will be attempted.
|
// If the version is mismatched, an automatic migration will be attempted.
|
||||||
@ -1972,14 +1986,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let blobs_sidecars_pruned = ops.len();
|
let blobs_sidecars_pruned = ops.len();
|
||||||
|
let new_blob_info = BlobInfo {
|
||||||
let update_blob_info = self.compare_and_set_blob_info(
|
oldest_blob_slot: Some(end_slot + 1),
|
||||||
blob_info,
|
blobs_db: blob_info.blobs_db,
|
||||||
BlobInfo {
|
};
|
||||||
oldest_blob_slot: Some(end_slot + 1),
|
let update_blob_info = self.compare_and_set_blob_info(blob_info, new_blob_info)?;
|
||||||
blobs_db: blob_info.blobs_db,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
ops.push(StoreOp::KeyValueOp(update_blob_info));
|
ops.push(StoreOp::KeyValueOp(update_blob_info));
|
||||||
|
|
||||||
self.do_atomically_with_block_and_blobs_cache(ops)?;
|
self.do_atomically_with_block_and_blobs_cache(ops)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user