Simplify do_process_blockstore_from_root slightly

This commit is contained in:
Michael Vines
2022-03-02 19:13:02 +01:00
parent b28acd2d4d
commit 93c8e04d51

View File

@ -695,16 +695,14 @@ fn do_process_blockstore_from_root(
let mut timing = ExecuteTimings::default(); let mut timing = ExecuteTimings::default();
// Iterate and replay slots from blockstore starting from `start_slot` // Iterate and replay slots from blockstore starting from `start_slot`
let (initial_forks, leader_schedule_cache) = { let mut leader_schedule_cache = LeaderScheduleCache::new_from_bank(&bank);
if let Some(meta) = blockstore
.meta(start_slot)
.unwrap_or_else(|_| panic!("Failed to get meta for slot {}", start_slot))
{
let epoch_schedule = bank.epoch_schedule();
let mut leader_schedule_cache = LeaderScheduleCache::new(*epoch_schedule, &bank);
if opts.full_leader_cache { if opts.full_leader_cache {
leader_schedule_cache.set_max_schedules(std::usize::MAX); leader_schedule_cache.set_max_schedules(std::usize::MAX);
} }
let initial_forks = if let Some(meta) = blockstore
.meta(start_slot)
.unwrap_or_else(|_| panic!("Failed to get meta for slot {}", start_slot))
{
let mut initial_forks = load_frozen_forks( let mut initial_forks = load_frozen_forks(
&bank, &bank,
&meta, &meta,
@ -721,15 +719,12 @@ fn do_process_blockstore_from_root(
&mut last_full_snapshot_slot, &mut last_full_snapshot_slot,
)?; )?;
initial_forks.sort_by_key(|bank| bank.slot()); initial_forks.sort_by_key(|bank| bank.slot());
initial_forks
(initial_forks, leader_schedule_cache)
} else { } else {
// If there's no meta for the input `start_slot`, then we started from a snapshot // If there's no meta for the input `start_slot`, then we started from a snapshot
// and there's no point in processing the rest of blockstore and implies blockstore // and there's no point in processing the rest of blockstore and implies blockstore
// should be empty past this point. // should be empty past this point.
let leader_schedule_cache = LeaderScheduleCache::new_from_bank(&bank); vec![bank]
(vec![bank], leader_schedule_cache)
}
}; };
if initial_forks.is_empty() { if initial_forks.is_empty() {
return Err(BlockstoreProcessorError::NoValidForksFound); return Err(BlockstoreProcessorError::NoValidForksFound);