handle empty blocks gracefully
This commit is contained in:
parent
8c341bb9cc
commit
97bffd03d0
@ -1189,7 +1189,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
&self,
|
&self,
|
||||||
block_root: &Hash256,
|
block_root: &Hash256,
|
||||||
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
|
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
|
||||||
Ok(self.store.get_blobs(block_root)?)
|
|
||||||
|
let blobs = self.store.get_blobs(block_root)?;
|
||||||
|
match Some(blobs) {
|
||||||
|
Some(blobs) => Ok(blobs),
|
||||||
|
None => {
|
||||||
|
// if there are no blobs, but a block exists return an empty list
|
||||||
|
if let Some(_) = self.store.try_get_full_block(block_root)? {
|
||||||
|
return Ok(Some(BlobSidecarList::default()))
|
||||||
|
}
|
||||||
|
// if there is no blob and no block return none.
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_blinded_block(
|
pub fn get_blinded_block(
|
||||||
|
@ -261,7 +261,7 @@ impl BlockId {
|
|||||||
match chain.get_blobs(&root) {
|
match chain.get_blobs(&root) {
|
||||||
Ok(Some(blob_sidecar_list)) => Ok(blob_sidecar_list),
|
Ok(Some(blob_sidecar_list)) => Ok(blob_sidecar_list),
|
||||||
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
|
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
|
||||||
"No blobs with block root {} found in the store",
|
"Block not found {} in the store",
|
||||||
root
|
root
|
||||||
))),
|
))),
|
||||||
Err(e) => Err(warp_utils::reject::beacon_chain_error(e)),
|
Err(e) => Err(warp_utils::reject::beacon_chain_error(e)),
|
||||||
|
Loading…
Reference in New Issue
Block a user