@@ -18,43 +18,39 @@ pub fn get_aggregate_attestation<T: BeaconChainTypes>(
18
18
endpoint_version : EndpointVersion ,
19
19
chain : Arc < BeaconChain < T > > ,
20
20
) -> Result < Response < Body > , warp:: reject:: Rejection > {
21
- if endpoint_version == V2 {
22
- let fork_name = chain. spec . fork_name_at_slot :: < T :: EthSpec > ( slot) ;
23
- let aggregate_attestation = if fork_name. electra_enabled ( ) {
24
- let Some ( committee_index) = committee_index else {
25
- return Err ( warp_utils:: reject:: custom_bad_request (
26
- "missing committee index" . to_string ( ) ,
27
- ) ) ;
28
- } ;
29
- chain
30
- . get_aggregated_attestation_electra ( slot, attestation_data_root, committee_index)
31
- . map_err ( |e| {
32
- warp_utils:: reject:: custom_bad_request ( format ! (
33
- "unable to fetch aggregate: {:?}" ,
34
- e
35
- ) )
36
- } ) ?
37
- . ok_or_else ( || {
38
- warp_utils:: reject:: custom_not_found ( "no matching aggregate found" . to_string ( ) )
39
- } ) ?
40
- } else {
41
- chain
42
- . get_pre_electra_aggregated_attestation_by_slot_and_root (
43
- slot,
44
- attestation_data_root,
45
- )
46
- . map_err ( |e| {
47
- warp_utils:: reject:: custom_bad_request ( format ! (
48
- "unable to fetch aggregate: {:?}" ,
49
- e
50
- ) )
51
- } ) ?
52
- . ok_or_else ( || {
53
- warp_utils:: reject:: custom_not_found ( "no matching aggregate found" . to_string ( ) )
54
- } ) ?
21
+ let fork_name = chain. spec . fork_name_at_slot :: < T :: EthSpec > ( slot) ;
22
+ let aggregate_attestation = if fork_name. electra_enabled ( ) {
23
+ let Some ( committee_index) = committee_index else {
24
+ return Err ( warp_utils:: reject:: custom_bad_request (
25
+ "missing committee index" . to_string ( ) ,
26
+ ) ) ;
55
27
} ;
28
+ chain
29
+ . get_aggregated_attestation_electra ( slot, attestation_data_root, committee_index)
30
+ . map_err ( |e| {
31
+ warp_utils:: reject:: custom_bad_request ( format ! (
32
+ "unable to fetch aggregate: {:?}" ,
33
+ e
34
+ ) )
35
+ } ) ?
36
+ . ok_or_else ( || {
37
+ warp_utils:: reject:: custom_not_found ( "no matching aggregate found" . to_string ( ) )
38
+ } ) ?
39
+ } else {
40
+ chain
41
+ . get_pre_electra_aggregated_attestation_by_slot_and_root ( slot, attestation_data_root)
42
+ . map_err ( |e| {
43
+ warp_utils:: reject:: custom_bad_request ( format ! (
44
+ "unable to fetch aggregate: {:?}" ,
45
+ e
46
+ ) )
47
+ } ) ?
48
+ . ok_or_else ( || {
49
+ warp_utils:: reject:: custom_not_found ( "no matching aggregate found" . to_string ( ) )
50
+ } ) ?
51
+ } ;
56
52
57
- let fork_name = chain . spec . fork_name_at_slot :: < T :: EthSpec > ( slot ) ;
53
+ if endpoint_version == V2 {
58
54
let fork_versioned_response = ForkVersionedResponse {
59
55
version : Some ( fork_name) ,
60
56
metadata : EmptyMetadata { } ,
@@ -65,19 +61,7 @@ pub fn get_aggregate_attestation<T: BeaconChainTypes>(
65
61
fork_name,
66
62
) )
67
63
} else if endpoint_version == V1 {
68
- let aggregate_attestation = chain
69
- . get_pre_electra_aggregated_attestation_by_slot_and_root ( slot, attestation_data_root)
70
- . map_err ( |e| {
71
- warp_utils:: reject:: custom_bad_request ( format ! (
72
- "unable to fetch aggregate: {:?}" ,
73
- e
74
- ) )
75
- } ) ?
76
- . map ( GenericResponse :: from)
77
- . ok_or_else ( || {
78
- warp_utils:: reject:: custom_not_found ( "no matching aggregate found" . to_string ( ) )
79
- } ) ?;
80
- Ok ( warp:: reply:: json ( & aggregate_attestation) . into_response ( ) )
64
+ Ok ( warp:: reply:: json ( & GenericResponse :: from ( aggregate_attestation) ) . into_response ( ) )
81
65
} else {
82
66
return Err ( unsupported_version_rejection ( endpoint_version) ) ;
83
67
}
0 commit comments