Skip to content

Commit

Permalink
Uses accounts run and snapshot dir constants (#34879)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Jan 23, 2024
1 parent 9caf9e8 commit 098076f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use {
append_vec::AppendVec,
hardened_unpack::{self, ParallelSelector, UnpackError},
shared_buffer_reader::{SharedBuffer, SharedBufferReader},
utils::delete_contents_of_path,
utils::{delete_contents_of_path, ACCOUNTS_RUN_DIR, ACCOUNTS_SNAPSHOT_DIR},
},
solana_measure::{measure, measure::Measure},
solana_sdk::{clock::Slot, hash::Hash},
Expand Down Expand Up @@ -1175,7 +1175,7 @@ fn get_account_path_from_appendvec_path(appendvec_path: &Path) -> Option<PathBuf
let run_file_name = run_path.file_name()?;
// All appendvec files should be under <account_path>/run/.
// When generating the bank snapshot directory, they are hardlinked to <account_path>/snapshot/<slot>/
if run_file_name != "run" {
if run_file_name != ACCOUNTS_RUN_DIR {
error!(
"The account path {} does not have run/ as its immediate parent directory.",
run_path.display()
Expand All @@ -1198,7 +1198,9 @@ fn get_snapshot_accounts_hardlink_dir(
GetSnapshotAccountsHardLinkDirError::GetAccountPath(appendvec_path.to_path_buf())
})?;

let snapshot_hardlink_dir = account_path.join("snapshot").join(bank_slot.to_string());
let snapshot_hardlink_dir = account_path
.join(ACCOUNTS_SNAPSHOT_DIR)
.join(bank_slot.to_string());

// Use the hashset to track, to avoid checking the file system. Only set up the hardlink directory
// and the symlink to it at the first time of seeing the account_path.
Expand Down Expand Up @@ -1539,7 +1541,7 @@ pub fn rebuild_storages_from_snapshot_dir(
.ok_or_else(|| SnapshotError::InvalidAccountPath(account_snapshot_path.clone()))?
.parent()
.ok_or_else(|| SnapshotError::InvalidAccountPath(account_snapshot_path.clone()))?
.join("run");
.join(ACCOUNTS_RUN_DIR);
if !account_run_paths.contains(&account_run_path) {
// The appendvec from the bank snapshot storage does not match any of the provided account_paths set.
// The accout paths have changed so the snapshot is no longer usable.
Expand Down

0 comments on commit 098076f

Please sign in to comment.