update beacon api aggregate attestationendpoint

This commit is contained in:
realbigsean
2024-05-09 21:19:59 -04:00
parent f9d4a28168
commit 6477eecc65

View File

@@ -3191,36 +3191,38 @@ pub fn serve<T: BeaconChainTypes>(
task_spawner: TaskSpawner<T::EthSpec>, task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>| { chain: Arc<BeaconChain<T>>| {
task_spawner.blocking_json_task(Priority::P0, move || { task_spawner.blocking_json_task(Priority::P0, move || {
if endpoint_version == V2 { not_synced_filter?;
if query.committee_index.is_none() { let res = if endpoint_version == V2 {
let Some(committee_index) = query.committee_index else {
return Err(warp_utils::reject::custom_bad_request( return Err(warp_utils::reject::custom_bad_request(
"missing committee index".to_string(), "missing committee index".to_string(),
)); ));
} };
chain.get_aggregated_attestation_electra(
&query.attestation_data_root,
committee_index,
)
} else if endpoint_version == V1 { } else if endpoint_version == V1 {
// Do nothing // Do nothing
} else { chain.get_pre_electra_aggregated_attestation_by_slot_and_root(
return Err(unsupported_version_rejection(endpoint_version));
}
//TODO(electra) pass the index into the next method.
not_synced_filter?;
chain
.get_pre_electra_aggregated_attestation_by_slot_and_root(
query.slot, query.slot,
&query.attestation_data_root, &query.attestation_data_root,
) )
.map_err(|e| { } else {
warp_utils::reject::custom_bad_request(format!( return Err(unsupported_version_rejection(endpoint_version));
"unable to fetch aggregate: {:?}", };
e res.map_err(|e| {
)) warp_utils::reject::custom_bad_request(format!(
})? "unable to fetch aggregate: {:?}",
.map(api_types::GenericResponse::from) e
.ok_or_else(|| { ))
warp_utils::reject::custom_not_found( })?
"no matching aggregate found".to_string(), .map(api_types::GenericResponse::from)
) .ok_or_else(|| {
}) warp_utils::reject::custom_not_found(
"no matching aggregate found".to_string(),
)
})
}) })
}, },
); );