Make Blockstore::get_data_shreds_for_slot() return type consistent (#32460)

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.
This commit is contained in:
steviez 2023-07-11 21:25:29 -05:00 committed by GitHub
parent d344ae5297
commit 04fab2b48f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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(|(_, bytes)| {
Shred::new_from_serialized_shred(bytes.to_vec()).map_err(|err| {
BlockstoreError::InvalidShredData(Box::new(bincode::ErrorKind::Custom(
format!("Could not reconstruct shred from shred payload: {err:?}"),
)))
})
})
.collect()
}