@@ -4,7 +4,7 @@ use crate::version::{
4
4
use beacon_chain:: { BeaconChain , BeaconChainError , BeaconChainTypes } ;
5
5
use eth2:: types:: {
6
6
self as api_types, ChainSpec , ForkVersionedResponse , LightClientUpdate ,
7
- LightClientUpdateResponseChunk , LightClientUpdateSszResponse , LightClientUpdatesQuery ,
7
+ LightClientUpdateResponseChunk , LightClientUpdateResponseChunkInner , LightClientUpdatesQuery ,
8
8
} ;
9
9
use ssz:: Encode ;
10
10
use std:: sync:: Arc ;
@@ -37,15 +37,9 @@ pub fn get_light_client_updates<T: BeaconChainTypes>(
37
37
. map ( |update| map_light_client_update_to_ssz_chunk :: < T > ( & chain, update) )
38
38
. collect :: < Vec < LightClientUpdateResponseChunk > > ( ) ;
39
39
40
- let ssz_response = LightClientUpdateSszResponse {
41
- response_chunk_len : ( light_client_updates. len ( ) as u64 ) . to_le_bytes ( ) . to_vec ( ) ,
42
- response_chunk : response_chunks. as_ssz_bytes ( ) ,
43
- }
44
- . as_ssz_bytes ( ) ;
45
-
46
40
Response :: builder ( )
47
41
. status ( 200 )
48
- . body ( ssz_response )
42
+ . body ( response_chunks . as_ssz_bytes ( ) )
49
43
. map ( |res : Response < Vec < u8 > > | add_ssz_content_type_header ( res) )
50
44
. map_err ( |e| {
51
45
warp_utils:: reject:: custom_server_error ( format ! (
@@ -159,16 +153,24 @@ fn map_light_client_update_to_ssz_chunk<T: BeaconChainTypes>(
159
153
) -> LightClientUpdateResponseChunk {
160
154
let fork_name = chain
161
155
. spec
162
- . fork_name_at_slot :: < T :: EthSpec > ( * light_client_update. signature_slot ( ) ) ;
156
+ . fork_name_at_slot :: < T :: EthSpec > ( light_client_update. attested_header_slot ( ) ) ;
163
157
164
158
let fork_digest = ChainSpec :: compute_fork_digest (
165
159
chain. spec . fork_version_for_name ( fork_name) ,
166
160
chain. genesis_validators_root ,
167
161
) ;
168
162
169
- LightClientUpdateResponseChunk {
163
+ let payload = light_client_update. as_ssz_bytes ( ) ;
164
+ let response_chunk_len = fork_digest. len ( ) + payload. len ( ) ;
165
+
166
+ let response_chunk = LightClientUpdateResponseChunkInner {
170
167
context : fork_digest,
171
- payload : light_client_update. as_ssz_bytes ( ) ,
168
+ payload,
169
+ } ;
170
+
171
+ LightClientUpdateResponseChunk {
172
+ response_chunk_len : response_chunk_len as u64 ,
173
+ response_chunk,
172
174
}
173
175
}
174
176
0 commit comments