@@ -9,9 +9,12 @@ use ethportal_api::consensus::{
99} ;
1010use ssz:: Encode ;
1111
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,
1518} ;
1619
1720pub const SLOTS_PER_HISTORICAL_ROOT : usize = 8192 ;
@@ -181,7 +184,7 @@ pub struct CompressedSignedBeaconBlock {
181184impl CompressedSignedBeaconBlock {
182185 pub fn try_from ( entry : & Entry , fork : ForkName ) -> Result < Self , anyhow:: Error > {
183186 ensure ! (
184- entry. header. type_ == 0x01 ,
187+ entry. header. type_ == entry_types :: COMPRESSED_SIGNED_BEACON_BLOCK ,
185188 "invalid compressed signed beacon block entry: incorrect header type"
186189 ) ;
187190
@@ -205,8 +208,10 @@ impl TryInto<Entry> for CompressedSignedBeaconBlock {
205208 let _ = snappy_encoder. write ( & ssz_encoded) ?;
206209 let snappy_encoded = snappy_encoder. into_inner ( ) ?;
207210
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+ ) )
210215 }
211216}
212217
@@ -218,7 +223,7 @@ pub struct CompressedBeaconState {
218223impl CompressedBeaconState {
219224 fn try_from ( entry : & Entry , fork : ForkName ) -> Result < Self , anyhow:: Error > {
220225 ensure ! (
221- entry. header. type_ == 0x02 ,
226+ entry. header. type_ == entry_types :: COMPRESSED_BEACON_STATE ,
222227 "invalid compressed beacon state entry: incorrect header type"
223228 ) ;
224229
@@ -242,8 +247,10 @@ impl TryInto<Entry> for CompressedBeaconState {
242247 let _ = snappy_encoder. write ( & ssz_encoded) ?;
243248 let snappy_encoded = snappy_encoder. into_inner ( ) ?;
244249
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+ ) )
247254 }
248255}
249256
@@ -263,7 +270,7 @@ impl TryFrom<&Entry> for SlotIndexBlockEntry {
263270
264271 fn try_from ( entry : & Entry ) -> Result < Self , Self :: Error > {
265272 ensure ! (
266- entry. header. type_ == 0x3269 ,
273+ entry. header. type_ == entry_types :: SLOT_INDEX ,
267274 "invalid slot index entry: incorrect header type"
268275 ) ;
269276 ensure ! (
@@ -296,7 +303,7 @@ impl TryInto<Entry> for SlotIndexBlockEntry {
296303 }
297304 buf. extend_from_slice ( & self . slot_index . count . to_le_bytes ( ) ) ;
298305
299- Ok ( Entry :: new ( 0x3269 , buf) )
306+ Ok ( Entry :: new ( entry_types :: SLOT_INDEX , buf) )
300307 }
301308}
302309
@@ -348,7 +355,7 @@ impl TryFrom<&Entry> for SlotIndexStateEntry {
348355
349356 fn try_from ( entry : & Entry ) -> Result < Self , Self :: Error > {
350357 ensure ! (
351- entry. header. type_ == 0x3269 ,
358+ entry. header. type_ == entry_types :: SLOT_INDEX ,
352359 "invalid slot index entry: incorrect header type"
353360 ) ;
354361 ensure ! (
@@ -381,7 +388,7 @@ impl TryInto<Entry> for SlotIndexStateEntry {
381388 }
382389 buf. extend_from_slice ( & self . slot_index . count . to_le_bytes ( ) ) ;
383390
384- Ok ( Entry :: new ( 0x3269 , buf) )
391+ Ok ( Entry :: new ( entry_types :: SLOT_INDEX , buf) )
385392 }
386393}
387394
0 commit comments