Skip to content

Commit

Permalink
Move status_cache_path out of SnapshotInfo. Add bank_snapshot_dir ins…
Browse files Browse the repository at this point in the history
…tead
  • Loading branch information
xiangzhu70 committed Jan 6, 2023
1 parent a68ca25 commit 5d983ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 6 additions & 4 deletions runtime/src/snapshot_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
snapshot_hash::SnapshotHash,
snapshot_utils::{
self, ArchiveFormat, BankSnapshotInfo, Result, SnapshotVersion,
TMP_BANK_SNAPSHOT_PREFIX,
SNAPSHOT_STATUS_CACHE_FILENAME, TMP_BANK_SNAPSHOT_PREFIX,
},
},
log::*,
Expand Down Expand Up @@ -97,10 +97,12 @@ impl AccountsPackage {
&bank_snapshot_info.snapshot_path,
snapshot_hardlink_dir.join(file_name),
)?;
let status_cache_file_name =
snapshot_utils::path_to_file_name_str(&bank_snapshot_info.status_cache_path)?;
let status_cache_path = bank_snapshot_info
.bank_snapshot_dir
.join(SNAPSHOT_STATUS_CACHE_FILENAME);
let status_cache_file_name = snapshot_utils::path_to_file_name_str(&status_cache_path)?;
fs::hard_link(
&bank_snapshot_info.status_cache_path,
&status_cache_path,
snapshot_links.path().join(status_cache_file_name),
)?;
}
Expand Down
14 changes: 6 additions & 8 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ impl SnapshotVersion {
pub struct BankSnapshotInfo {
/// Slot of the bank
pub slot: Slot,
/// Path to the snapshot
/// Path to the snapshot file
pub snapshot_path: PathBuf,
/// Type of the snapshot
pub snapshot_type: BankSnapshotType,
/// Path to the status cache (transaction history)
pub status_cache_path: PathBuf,
/// Path to the bank snapshot directory
pub bank_snapshot_dir: PathBuf,
}

impl PartialOrd for BankSnapshotInfo {
Expand Down Expand Up @@ -597,8 +597,6 @@ pub fn get_bank_snapshots(bank_snapshots_dir: impl AsRef<Path>) -> Vec<BankSnaps
let bank_snapshot_outer_dir = get_bank_snapshots_dir(&bank_snapshots_dir, slot);
let bank_snapshot_post_path =
bank_snapshot_outer_dir.join(get_snapshot_file_name(slot));
let status_cache_path =
bank_snapshot_outer_dir.join(SNAPSHOT_STATUS_CACHE_FILENAME);
let mut bank_snapshot_pre_path = bank_snapshot_post_path.clone();
bank_snapshot_pre_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION);

Expand All @@ -607,7 +605,7 @@ pub fn get_bank_snapshots(bank_snapshots_dir: impl AsRef<Path>) -> Vec<BankSnaps
slot,
snapshot_path: bank_snapshot_pre_path,
snapshot_type: BankSnapshotType::Pre,
status_cache_path: status_cache_path.clone(),
bank_snapshot_dir: bank_snapshot_outer_dir.clone(),
});
}

Expand All @@ -616,7 +614,7 @@ pub fn get_bank_snapshots(bank_snapshots_dir: impl AsRef<Path>) -> Vec<BankSnaps
slot,
snapshot_path: bank_snapshot_post_path,
snapshot_type: BankSnapshotType::Post,
status_cache_path,
bank_snapshot_dir: bank_snapshot_outer_dir,
});
}
}),
Expand Down Expand Up @@ -901,7 +899,7 @@ pub fn add_bank_snapshot(
slot,
snapshot_path: bank_snapshot_path,
snapshot_type: BankSnapshotType::Pre,
status_cache_path,
bank_snapshot_dir,
})
}

Expand Down

0 comments on commit 5d983ef

Please sign in to comment.