@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
18 lines • 923 B
JavaScript
import { RespStatus, ResponseError } from "@lodestar/reqresp";
import { computeEpochAtSlot } from "@lodestar/state-transition";
import { assertLightClientServer } from "../../../node/utils/lightclient.js";
import { ReqRespMethod, responseSszTypeByMethod } from "../types.js";
export async function* onLightClientFinalityUpdate(chain) {
assertLightClientServer(chain.lightClientServer);
const update = chain.lightClientServer.getFinalityUpdate();
if (update === null) {
throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, "No latest finality update available");
}
const boundary = chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(update.signatureSlot));
const type = responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate](boundary.fork, 0);
yield {
data: type.serialize(update),
boundary,
};
}
//# sourceMappingURL=lightClientFinalityUpdate.js.map