Skip to content

Commit 6ac0887

Browse files
committed
fix docs
1 parent 374c32d commit 6ac0887

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/era/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const reader = await era.EraReader.open(config, "mainnet-xxxxx-xxxxxxxx.era");
3030
reader.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
5353
import {era} from "@lodestar/era";
5454
import {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;
6063
await writer.writeBlock(block);
6164
// ...
6265
// then write the state
66+
// Assuming `state` is a BeaconState
67+
declare const state: BeaconState;
6368
await 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

Comments
 (0)