@@ -30,7 +30,7 @@ const reader = await era.EraReader.open(config, "mainnet-xxxxx-xxxxxxxx.era");
3030reader .groups .length === 1 ;
3131
3232// read blocks
33- const slot = reader .groups [0 ].startSlot ;
33+ const slot = reader .groups [0 ].blocksIndex ?. startSlot ?? 0 ;
3434
3535// return snappy-frame compressed, ssz-serialized block at slot or null if a skip slot
3636// throws if out of range
@@ -52,14 +52,19 @@ await reader.readState();
5252``` ts
5353import {era } from " @lodestar/era" ;
5454import {config } from " @lodestar/config/default" ;
55+ import {SignedBeaconBlock , BeaconState } from " @lodestar/types" ;
5556
56- const writer = await era .EraWriter .create (config , " path/to/era" );
57+ const writer = await era .EraWriter .create (config , " path/to/era" , 0 );
5758
5859// similar api to reader, can write compressed, serialized, or deserialized items
5960// first write all blocks for the era
61+ // Assuming `block` is a SignedBeaconBlock
62+ declare const block: SignedBeaconBlock ;
6063await writer .writeBlock (block );
6164// ...
6265// then write the state
66+ // Assuming `state` is a BeaconState
67+ declare const state: BeaconState ;
6368await writer .writeState (state );
6469// if applicable, continue writing eras of blocks and state (an era file can contain multiple eras, or "groups" as the spec states)
6570// when finished, must call `finish`, which will close the file handler and rename the file to the spec-compliant name
0 commit comments