UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

67 lines 2.23 kB
import { GossipSub } from "@chainsafe/libp2p-gossipsub"; import { PeerScoreParams } from "@chainsafe/libp2p-gossipsub/score"; import { BeaconConfig } from "@lodestar/config"; import { Logger } from "@lodestar/utils"; import { RegistryMetricCreator } from "../../metrics/index.js"; import { NetworkEventBus } from "../events.js"; import { Libp2p } from "../interface.js"; import { PeersData } from "../peers/peersData.js"; import { GossipTopic } from "./interface.js"; export type Eth2Context = { activeValidatorCount: number; currentSlot: number; currentEpoch: number; }; export type Eth2GossipsubModules = { config: BeaconConfig; libp2p: Libp2p; logger: Logger; metricsRegister: RegistryMetricCreator | null; eth2Context: Eth2Context; peersData: PeersData; events: NetworkEventBus; }; export type Eth2GossipsubOpts = { allowPublishToZeroPeers?: boolean; gossipsubD?: number; gossipsubDLow?: number; gossipsubDHigh?: number; gossipsubAwaitHandler?: boolean; disableFloodPublish?: boolean; skipParamsLog?: boolean; disableLightClientServer?: boolean; }; /** * Wrapper around js-libp2p-gossipsub with the following extensions: * - Eth2 message id * - Emits `GossipObject`, not `InMessage` * - Provides convenience interface: * - `publishObject` * - `subscribeTopic` * - `unsubscribeTopic` * - `handleTopic` * - `unhandleTopic` * * See https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#the-gossip-domain-gossipsub */ export declare class Eth2Gossipsub extends GossipSub { readonly scoreParams: Partial<PeerScoreParams>; private readonly config; private readonly logger; private readonly peersData; private readonly events; private readonly gossipTopicCache; constructor(opts: Eth2GossipsubOpts, modules: Eth2GossipsubModules); /** * Subscribe to a `GossipTopic` */ subscribeTopic(topic: GossipTopic): void; /** * Unsubscribe to a `GossipTopic` */ unsubscribeTopic(topic: GossipTopic): void; private onScrapeLodestarMetrics; private onGossipsubMessage; private onValidationResult; } //# sourceMappingURL=gossipsub.d.ts.map