diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 80a5199477a235..79860b6b99d050 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -193,7 +193,7 @@ impl BankSnapshotInfo { // filled. Check the completion to avoid using a highest found slot directory with missing content. let completion_flag_file = bank_snapshot_dir.join(SNAPSHOT_STATE_COMPLETE_FILENAME); if !fs::metadata(&completion_flag_file)?.is_file() { - return Err(SnapshotNewFromDirError::DirIncomplete(completion_flag_file)); + return Err(SnapshotNewFromDirError::IncompleteDir(completion_flag_file)); } let bank_snapshot_post_path = bank_snapshot_dir.join(get_snapshot_file_name(slot)); @@ -347,9 +347,9 @@ pub enum SnapshotNewFromDirError { InvalidVersion, #[error("snapshot directory incomplete {}", .0.display())] - DirIncomplete(PathBuf), + IncompleteDir(PathBuf), - #[error("missing snapshotfile {}", .0.display())] + #[error("missing snapshot file {}", .0.display())] MissingSnapshotFile(PathBuf), } @@ -747,6 +747,13 @@ pub fn get_highest_bank_snapshot_post( do_get_highest_bank_snapshot(get_bank_snapshots_post(bank_snapshots_dir)) } +/// Get the bank snapshot with the highest slot in a directory +/// +/// This function gets the highest bank snapshot of any type +pub fn get_highest_bank_snapshot(bank_snapshots_dir: impl AsRef) -> Option { + do_get_highest_bank_snapshot(get_bank_snapshots(&bank_snapshots_dir)) +} + fn do_get_highest_bank_snapshot( mut bank_snapshots: Vec, ) -> Option { @@ -1916,15 +1923,6 @@ pub fn get_highest_incremental_snapshot_archive_slot( .map(|incremental_snapshot_archive_info| incremental_snapshot_archive_info.slot()) } -/// Get the full snapshot with the highest slot in a directory -/// Assume every bank snapshot directory is a full snapshot for now. Will support incremental sanpshot -/// later. -pub fn get_highest_bank_snapshot(snapshots_dir: impl AsRef) -> Result { - let bank_snapshots = get_bank_snapshots(&snapshots_dir); - do_get_highest_bank_snapshot(bank_snapshots) - .ok_or_else(|| SnapshotError::NoSnapshotSlotDir(snapshots_dir.as_ref().to_path_buf())) -} - /// Get the path (and metadata) for the full snapshot archive with the highest slot in a directory pub fn get_highest_full_snapshot_archive_info( full_snapshot_archives_dir: impl AsRef,