UNPKG

@waku/core

Version:

TypeScript implementation of the Waku v2 protocol

47 lines (46 loc) 1.63 kB
import { ConnectionManagerOptions, IWakuEventEmitter, Libp2p } from "@waku/interfaces"; import { Dialer } from "./dialer.js"; import { NetworkMonitor } from "./network_monitor.js"; type ConnectionLimiterConstructorOptions = { libp2p: Libp2p; events: IWakuEventEmitter; dialer: Dialer; networkMonitor: NetworkMonitor; options: ConnectionManagerOptions; }; interface IConnectionLimiter { start(): void; stop(): void; } /** * This class is responsible for limiting the number of connections to peers. * It also dials all known peers because libp2p might have emitted `peer:discovery` before initialization * and listen to `peer:connect` and `peer:disconnect` events to manage connections. */ export declare class ConnectionLimiter implements IConnectionLimiter { private readonly libp2p; private readonly events; private readonly networkMonitor; private readonly dialer; private connectionMonitorInterval; private readonly options; constructor(options: ConnectionLimiterConstructorOptions); start(): void; stop(): void; private onWakuConnectionEvent; private maintainConnections; private onDisconnectedEvent; private maintainConnectionsCount; private maintainBootstrapConnections; private dialPeersFromStore; /** * Returns a list of peers ordered by priority: * - bootstrap peers * - peers from peer exchange * - peers from local store (last because we are not sure that locally stored information is up to date) */ private getPrioritizedPeers; private getBootstrapPeers; private getPeer; } export {};