mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 10:43:42 +00:00
Add Beacon API endpoint to download blobs by block ID
This commit is contained in:
@@ -3324,6 +3324,41 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
)))
|
||||
});
|
||||
|
||||
// GET lighthouse/beacon/blob_sidecars/{block_id}
|
||||
let get_blob_sidecars = warp::path("lighthouse")
|
||||
.and(warp::path("beacon"))
|
||||
.and(warp::path("blob_sidecars"))
|
||||
.and(block_id_or_err)
|
||||
.and(warp::path::end())
|
||||
.and(chain_filter.clone())
|
||||
.and(warp::header::optional::<api_types::Accept>("accept"))
|
||||
.and_then(
|
||||
|block_id: BlockId,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
accept_header: Option<api_types::Accept>| {
|
||||
async move {
|
||||
let blobs_sidecar = block_id.blobs_sidecar(&chain).await?;
|
||||
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/octet-stream")
|
||||
.body(blobs_sidecar.as_ssz_bytes().into())
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"failed to create response: {}",
|
||||
e
|
||||
))
|
||||
}),
|
||||
_ => Ok(warp::reply::json(&api_types::GenericResponse::from(
|
||||
blobs_sidecar,
|
||||
))
|
||||
.into_response()),
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let get_events = eth_v1
|
||||
.and(warp::path("events"))
|
||||
.and(warp::path::end())
|
||||
|
||||
Reference in New Issue
Block a user