From 5d257bceea9cae06a01568e6ecd6039308b6fa0b Mon Sep 17 00:00:00 2001 From: steviez Date: Wed, 8 May 2024 19:20:53 -0500 Subject: [PATCH] Remove explicit assert in Blockstore::get_slot_entries_in_block() 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. --- ledger/src/blockstore.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index bd961f59d12be7..31c1c13759ce26 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -3515,10 +3515,12 @@ impl Blockstore { completed_ranges: CompletedRanges, slot_meta: Option<&SlotMeta>, ) -> Result> { - 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)));