mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Add Changes to BlobSidecars Endpoint (#4455)
* changed name * Fix sidecars * Added query type and parrameter * added query struct and function * added method * improved filtering method * added blob_sidecar_list_indexed to block_id * minor blobqueryindex fix * function and formatting fix * minor function and naming fix * minor changes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::{state_id::checkpoint_slot_and_execution_optimistic, ExecutionOptimistic};
|
||||
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes, WhenSlotSkipped};
|
||||
use eth2::types::BlobIndicesQuery;
|
||||
use eth2::types::BlockId as CoreBlockId;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
@@ -266,6 +267,26 @@ impl BlockId {
|
||||
Err(e) => Err(warp_utils::reject::beacon_chain_error(e)),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn blob_sidecar_list_filtered<T: BeaconChainTypes>(
|
||||
&self,
|
||||
indices: BlobIndicesQuery,
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
|
||||
let blob_sidecar_list = self.blob_sidecar_list(&chain).await?;
|
||||
let blob_sidecar_list_filtered = match indices.indices {
|
||||
Some(vec) => {
|
||||
let list = blob_sidecar_list
|
||||
.into_iter()
|
||||
.filter(|blob_sidecar| vec.contains(&blob_sidecar.index))
|
||||
.collect();
|
||||
BlobSidecarList::new(list)
|
||||
.map_err(|e| warp_utils::reject::custom_server_error(format!("{:?}", e)))?
|
||||
}
|
||||
None => blob_sidecar_list,
|
||||
};
|
||||
Ok(blob_sidecar_list_filtered)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for BlockId {
|
||||
|
||||
Reference in New Issue
Block a user