Skip to content

Commit

Permalink
Use flags to make the function calls more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangzhu70 committed Apr 13, 2023
1 parent f88f84f commit fe52ee6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ fn test_concurrent_snapshot_packaging(

// Purge all the outdated snapshots, including the ones needed to generate the package
// currently sitting in the channel
snapshot_utils::purge_old_bank_snapshots(bank_snapshots_dir, MAX_BANK_SNAPSHOTS_TO_RETAIN, None);
snapshot_utils::purge_old_bank_snapshots(
bank_snapshots_dir,
MAX_BANK_SNAPSHOTS_TO_RETAIN,
None,
);

let mut bank_snapshots = snapshot_utils::get_bank_snapshots_pre(bank_snapshots_dir);
bank_snapshots.sort_unstable();
Expand Down
6 changes: 5 additions & 1 deletion local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,11 @@ fn test_incremental_snapshot_download_with_crossing_full_snapshot_interval_at_st
// To restart, it is not enough to remove the old bank snapshot directories under snapshot/.
// The old hardlinks under <account_path>/snapshot/<slot> should also be removed.
// The purge call covers all of them.
snapshot_utils::purge_old_bank_snapshots(validator_snapshot_test_config.bank_snapshots_dir, 0, None);
snapshot_utils::purge_old_bank_snapshots(
validator_snapshot_test_config.bank_snapshots_dir,
0,
None,
);
cluster.restart_node(
&validator_identity.pubkey(),
validator_info,
Expand Down
14 changes: 12 additions & 2 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2901,18 +2901,28 @@ pub fn purge_old_bank_snapshots(
})
};

let mut select_pre = false;
let mut select_post = false;
match type_select {
Some(BankSnapshotType::Pre) => {
select_pre = true;
do_purge(get_bank_snapshots_pre(&bank_snapshots_dir));
}
Some(BankSnapshotType::Post) => {
select_post = true;
do_purge(get_bank_snapshots_post(&bank_snapshots_dir));
}
None => {
do_purge(get_bank_snapshots_pre(&bank_snapshots_dir));
do_purge(get_bank_snapshots_post(&bank_snapshots_dir));
select_pre = true;
select_post = true;
}
}
if select_pre {
do_purge(get_bank_snapshots_pre(&bank_snapshots_dir));
}
if select_post {
do_purge(get_bank_snapshots_post(&bank_snapshots_dir));
}
}

/// Get the snapshot storages for this bank
Expand Down

0 comments on commit fe52ee6

Please sign in to comment.