Skip to content

Commit

Permalink
Bugfix: Account Shrink Paths must conform to account directory struct…
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored and wen-coding committed Aug 15, 2023
1 parent 51019be commit e673be9
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,24 +1410,42 @@ pub fn main() {
values_t!(matches, "account_shrink_path", String)
.map(|shrink_paths| shrink_paths.into_iter().map(PathBuf::from).collect())
.ok();
let account_shrink_paths = account_shrink_paths.as_ref().map(|paths| {
create_and_canonicalize_directories(paths).unwrap_or_else(|err| {
eprintln!("Unable to access account shrink path: {err}");
exit(1);
})
});

let (account_run_paths, account_snapshot_paths) =
create_all_accounts_run_and_snapshot_dirs(&account_paths).unwrap_or_else(|err| {
eprintln!("Error: {err:?}");
eprintln!("Error: {err}");
exit(1);
});

let (account_shrink_run_paths, account_shrink_snapshot_paths) = account_shrink_paths
.map(|paths| {
create_all_accounts_run_and_snapshot_dirs(&paths).unwrap_or_else(|err| {
eprintln!("Error: {err}");
exit(1);
})
})
.unzip();

// From now on, use run/ paths in the same way as the previous account_paths.
validator_config.account_paths = account_run_paths;
validator_config.account_shrink_paths = account_shrink_run_paths;

validator_config.account_snapshot_paths = account_snapshot_paths;

validator_config.account_shrink_paths = account_shrink_paths.map(|paths| {
create_and_canonicalize_directories(&paths).unwrap_or_else(|err| {
eprintln!("Unable to access account shrink path: {err}");
exit(1);
})
});
// These snapshot paths are only used for initial clean up, add in shrink paths if they exist.
validator_config.account_snapshot_paths =
if let Some(account_shrink_snapshot_paths) = account_shrink_snapshot_paths {
account_snapshot_paths
.into_iter()
.chain(account_shrink_snapshot_paths.into_iter())
.collect()
} else {
account_snapshot_paths
};

let maximum_local_snapshot_age = value_t_or_exit!(matches, "maximum_local_snapshot_age", u64);
let maximum_full_snapshot_archives_to_retain =
Expand Down

0 comments on commit e673be9

Please sign in to comment.