UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

23 lines 1.16 kB
import { computeEpochAtSlot } from "@lodestar/state-transition"; import { toRootHex } from "@lodestar/utils"; export async function* onExecutionPayloadEnvelopesByRoot(requestBody, chain, db) { // The gloas req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve. // Archival nodes may still serve older retained payloads to allow genesis sync. for (const root of requestBody) { const rootHex = toRootHex(root); const block = chain.forkChoice.getBlockHexDefaultStatus(rootHex); // If the block is not in fork choice, it may be finalized. Attempt to find its slot in block archive const slot = block ? block.slot : await db.blockArchive.getSlotByRoot(root); if (slot === null) { continue; } const envelopeBytes = await chain.getSerializedExecutionPayloadEnvelope(slot, rootHex); if (envelopeBytes) { yield { data: envelopeBytes, boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(slot)), }; } } } //# sourceMappingURL=executionPayloadEnvelopesByRoot.js.map