@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
14 lines • 658 B
JavaScript
/**
* Utility for fetching genesis min genesis time block
* Returns an approximation of the next block diff to fetch to progressively
* get closer to the block that satisfies min genesis time condition
*/
export function optimizeNextBlockDiffForGenesis(lastFetchedBlock, params) {
const timeToGenesis = params.MIN_GENESIS_TIME - params.GENESIS_DELAY - lastFetchedBlock.timestamp;
const numBlocksToGenesis = Math.floor(timeToGenesis / params.SECONDS_PER_ETH1_BLOCK);
if (numBlocksToGenesis <= 2) {
return 1;
}
return Math.max(1, Math.floor(numBlocksToGenesis / 2));
}
//# sourceMappingURL=optimizeNextBlockDiffForGenesis.js.map