Skip to content

Commit

Permalink
Remove explicit assert in Blockstore::get_slot_entries_in_block() (an…
Browse files Browse the repository at this point in the history
…za-xyz#1258)

This is a private function and the callers should NOT be calling with an
empty completed range vector. Regardless, it is safer to just return an
empty Entry vector should an empty CompletedRanges be provided as input.
  • Loading branch information
steviez authored May 9, 2024
1 parent 979f619 commit c84c478
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3515,10 +3515,12 @@ impl Blockstore {
completed_ranges: CompletedRanges,
slot_meta: Option<&SlotMeta>,
) -> Result<Vec<Entry>> {
assert!(!completed_ranges.is_empty());

let (all_ranges_start_index, _) = *completed_ranges.first().unwrap();
let (_, all_ranges_end_index) = *completed_ranges.last().unwrap();
let Some((all_ranges_start_index, _)) = completed_ranges.first().copied() else {
return Ok(vec![]);
};
let Some((_, all_ranges_end_index)) = completed_ranges.last().copied() else {
return Ok(vec![]);
};
let keys =
(all_ranges_start_index..=all_ranges_end_index).map(|index| (slot, u64::from(index)));

Expand Down

0 comments on commit c84c478

Please sign in to comment.