UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

72 lines 3.42 kB
import { PeerId } from "@libp2p/interface"; import { BeaconConfig, ForkBoundary } from "@lodestar/config"; import { ProtocolDescriptor, ReqResp, ReqRespOpts, RequestError, ResponseIncoming } from "@lodestar/reqresp"; import { Metadata, phase0 } from "@lodestar/types"; import { Logger } from "@lodestar/utils"; import { Libp2p } from "libp2p"; import { NetworkCoreMetrics } from "../core/metrics.js"; import { INetworkEventBus } from "../events.js"; import { MetadataController } from "../metadata.js"; import { PeersData } from "../peers/peersData.js"; import { IPeerRpcScoreStore } from "../peers/score/index.js"; import { StatusCache } from "../statusCache.js"; import { GetReqRespHandlerFn, ReqRespMethod, RequestTypedContainer } from "./types.js"; export { getReqRespHandlers } from "./handlers/index.js"; export { ReqRespMethod, type RequestTypedContainer } from "./types.js"; export interface ReqRespBeaconNodeModules { libp2p: Libp2p; peersData: PeersData; logger: Logger; config: BeaconConfig; metrics: NetworkCoreMetrics | null; metadata: MetadataController; peerRpcScores: IPeerRpcScoreStore; events: INetworkEventBus; statusCache: StatusCache; getHandler: GetReqRespHandlerFn; } export type ReqRespBeaconNodeOpts = ReqRespOpts & { disableLightClientServer?: boolean; }; /** * Implementation of Ethereum Consensus p2p Req/Resp domain. * For the spec that this code is based on, see: * https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#the-reqresp-domain * https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md#the-reqresp-domain */ export declare class ReqRespBeaconNode extends ReqResp { private readonly metadataController; private readonly peerRpcScores; private readonly networkEventBus; private readonly peersData; private readonly statusCache; private readonly getHandler; /** Track registered fork to only send to known protocols */ private currentRegisteredFork; private readonly config; protected readonly logger: Logger; protected readonly disableLightClientServer: boolean; constructor(modules: ReqRespBeaconNodeModules, options?: ReqRespBeaconNodeOpts); start(): Promise<void>; stop(): Promise<void>; registerProtocolsAtBoundary(boundary: ForkBoundary): void; sendRequestWithoutEncoding(peerId: PeerId, method: ReqRespMethod, versions: number[], requestData: Uint8Array): AsyncIterable<ResponseIncoming>; sendPing(peerId: PeerId): Promise<phase0.Ping>; sendStatus(peerId: PeerId, request: phase0.Status): Promise<phase0.Status>; sendGoodbye(peerId: PeerId, request: phase0.Goodbye): Promise<void>; sendMetadata(peerId: PeerId): Promise<Metadata>; private sendReqRespRequest; /** * Returns the list of protocols that must be subscribed during a specific fork. * Any protocol not in this list must be un-subscribed. */ private getProtocolsAtBoundary; protected onIncomingRequestBody(request: RequestTypedContainer, peer: PeerId): void; protected onIncomingRequest(peerId: PeerId, protocol: ProtocolDescriptor): void; protected onOutgoingRequestError(peerId: PeerId, method: ReqRespMethod, error: RequestError): void; private onStatus; private onGoodbye; private onPing; private onMetadata; } //# sourceMappingURL=ReqRespBeaconNode.d.ts.map