Special case slot 0 for block connectness check in ledger tool (#29860)

* special case is_connected check for slot 0 so that we can load snapshot 0 for gce cluster boostrapting

* remove obsolete comments

* refactor with match expr

* update comments

* Update ledger-tool/src/main.rs

Co-authored-by: steviez <steven@solana.com>

* Update ledger-tool/src/main.rs

Co-authored-by: steviez <steven@solana.com>

Co-authored-by: steviez <steven@solana.com>
This commit is contained in:
HaoranYi 2023-01-25 09:06:22 -06:00 committed by GitHub
parent 40bbf99c74
commit 2194551f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 10 deletions

View File

@ -1065,19 +1065,26 @@ fn load_bank_forks(
})
};
if let Some(halt_slot) = process_options.halt_at_slot {
if halt_slot < starting_slot {
eprintln!(
match process_options.halt_at_slot {
// Skip the following checks for sentinel values of Some(0) and None.
// For Some(0), no slots will be be replayed after starting_slot.
// For None, all available children of starting_slot will be replayed.
None | Some(0) => {}
Some(halt_slot) => {
if halt_slot < starting_slot {
eprintln!(
"Unable to load bank forks at slot {halt_slot} because it is less than the starting slot {starting_slot}. \
The starting slot will be the latest snapshot slot, or genesis if --no-snapshot flag specified or no snapshots found."
);
exit(1);
}
// Check if we have the slot data necessary to replay from starting_slot to <= halt_slot.
// - This will not catch the case when loading from genesis without a full slot 0.
if !blockstore.slot_range_connected(starting_slot, halt_slot) {
eprintln!("Unable to load bank forks at slot {halt_slot} due to disconnected blocks.",);
exit(1);
exit(1);
}
// Check if we have the slot data necessary to replay from starting_slot to >= halt_slot.
if !blockstore.slot_range_connected(starting_slot, halt_slot) {
eprintln!(
"Unable to load bank forks at slot {halt_slot} due to disconnected blocks.",
);
exit(1);
}
}
}