Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Make Blockstore::get_data_shreds_for_slot() return type consistent
Browse files Browse the repository at this point in the history
We have several other functions that return data shreds; however, these
other functions map shred::Error to BlockstoreError. Make this function
consistent with those and map the error.
  • Loading branch information
Steven Czabaniuk committed Jul 11, 2023
1 parent 0a1e641 commit 2a8380a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,14 +1636,16 @@ impl Blockstore {
})
}

pub fn get_data_shreds_for_slot(
&self,
slot: Slot,
start_index: u64,
) -> std::result::Result<Vec<Shred>, shred::Error> {
pub fn get_data_shreds_for_slot(&self, slot: Slot, start_index: u64) -> Result<Vec<Shred>> {
self.slot_data_iterator(slot, start_index)
.expect("blockstore couldn't fetch iterator")
.map(|data| Shred::new_from_serialized_shred(data.1.to_vec()))
.map(|data| {
Shred::new_from_serialized_shred(data.1.to_vec()).map_err(|err| {
BlockstoreError::InvalidShredData(Box::new(bincode::ErrorKind::Custom(
format!("Could not reconstruct shred from shred payload: {err:?}"),
)))
})
})
.collect()
}

Expand Down

0 comments on commit 2a8380a

Please sign in to comment.