@@ -9,9 +9,12 @@ use ethportal_api::consensus::{
9
9
} ;
10
10
use ssz:: Encode ;
11
11
12
- use crate :: e2store:: {
13
- memory:: E2StoreMemory ,
14
- types:: { Entry , Header , VersionEntry } ,
12
+ use crate :: {
13
+ e2store:: {
14
+ memory:: E2StoreMemory ,
15
+ types:: { Entry , Header , VersionEntry } ,
16
+ } ,
17
+ entry_types,
15
18
} ;
16
19
17
20
pub const SLOTS_PER_HISTORICAL_ROOT : usize = 8192 ;
@@ -181,7 +184,7 @@ pub struct CompressedSignedBeaconBlock {
181
184
impl CompressedSignedBeaconBlock {
182
185
pub fn try_from ( entry : & Entry , fork : ForkName ) -> Result < Self , anyhow:: Error > {
183
186
ensure ! (
184
- entry. header. type_ == 0x01 ,
187
+ entry. header. type_ == entry_types :: COMPRESSED_SIGNED_BEACON_BLOCK ,
185
188
"invalid compressed signed beacon block entry: incorrect header type"
186
189
) ;
187
190
@@ -205,8 +208,10 @@ impl TryInto<Entry> for CompressedSignedBeaconBlock {
205
208
let _ = snappy_encoder. write ( & ssz_encoded) ?;
206
209
let snappy_encoded = snappy_encoder. into_inner ( ) ?;
207
210
208
- let header = 0x01 ;
209
- Ok ( Entry :: new ( header, snappy_encoded) )
211
+ Ok ( Entry :: new (
212
+ entry_types:: COMPRESSED_SIGNED_BEACON_BLOCK ,
213
+ snappy_encoded,
214
+ ) )
210
215
}
211
216
}
212
217
@@ -218,7 +223,7 @@ pub struct CompressedBeaconState {
218
223
impl CompressedBeaconState {
219
224
fn try_from ( entry : & Entry , fork : ForkName ) -> Result < Self , anyhow:: Error > {
220
225
ensure ! (
221
- entry. header. type_ == 0x02 ,
226
+ entry. header. type_ == entry_types :: COMPRESSED_BEACON_STATE ,
222
227
"invalid compressed beacon state entry: incorrect header type"
223
228
) ;
224
229
@@ -242,8 +247,10 @@ impl TryInto<Entry> for CompressedBeaconState {
242
247
let _ = snappy_encoder. write ( & ssz_encoded) ?;
243
248
let snappy_encoded = snappy_encoder. into_inner ( ) ?;
244
249
245
- let header = 0x02 ;
246
- Ok ( Entry :: new ( header, snappy_encoded) )
250
+ Ok ( Entry :: new (
251
+ entry_types:: COMPRESSED_BEACON_STATE ,
252
+ snappy_encoded,
253
+ ) )
247
254
}
248
255
}
249
256
@@ -263,7 +270,7 @@ impl TryFrom<&Entry> for SlotIndexBlockEntry {
263
270
264
271
fn try_from ( entry : & Entry ) -> Result < Self , Self :: Error > {
265
272
ensure ! (
266
- entry. header. type_ == 0x3269 ,
273
+ entry. header. type_ == entry_types :: SLOT_INDEX ,
267
274
"invalid slot index entry: incorrect header type"
268
275
) ;
269
276
ensure ! (
@@ -296,7 +303,7 @@ impl TryInto<Entry> for SlotIndexBlockEntry {
296
303
}
297
304
buf. extend_from_slice ( & self . slot_index . count . to_le_bytes ( ) ) ;
298
305
299
- Ok ( Entry :: new ( 0x3269 , buf) )
306
+ Ok ( Entry :: new ( entry_types :: SLOT_INDEX , buf) )
300
307
}
301
308
}
302
309
@@ -348,7 +355,7 @@ impl TryFrom<&Entry> for SlotIndexStateEntry {
348
355
349
356
fn try_from ( entry : & Entry ) -> Result < Self , Self :: Error > {
350
357
ensure ! (
351
- entry. header. type_ == 0x3269 ,
358
+ entry. header. type_ == entry_types :: SLOT_INDEX ,
352
359
"invalid slot index entry: incorrect header type"
353
360
) ;
354
361
ensure ! (
@@ -381,7 +388,7 @@ impl TryInto<Entry> for SlotIndexStateEntry {
381
388
}
382
389
buf. extend_from_slice ( & self . slot_index . count . to_le_bytes ( ) ) ;
383
390
384
- Ok ( Entry :: new ( 0x3269 , buf) )
391
+ Ok ( Entry :: new ( entry_types :: SLOT_INDEX , buf) )
385
392
}
386
393
}
387
394
0 commit comments