UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

17 lines 774 B
import { computeEpochAtSlot } from "@lodestar/state-transition"; import { toRootHex } from "@lodestar/utils"; export async function* onBeaconBlocksByRoot(requestBody, chain) { // The phase0 req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve. // Archival nodes may still serve older retained blocks to allow genesis sync. for (const blockRoot of requestBody) { const root = blockRoot; const block = await chain.getSerializedBlockByRoot(toRootHex(root)); if (block) { yield { data: block.block, boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(block.slot)), }; } } } //# sourceMappingURL=beaconBlocksByRoot.js.map