@waku/discovery
Version:
Contains various discovery mechanisms: DNS Discovery (EIP-1459, Peer Exchange, Local Peer Cache Discovery.
43 lines (42 loc) • 1.55 kB
TypeScript
import { TypedEventEmitter } from "@libp2p/interface";
import { peerDiscoverySymbol as symbol } from "@libp2p/interface";
import type { PeerDiscovery, PeerDiscoveryEvents } from "@libp2p/interface";
import { type Libp2pComponents } from "@waku/interfaces";
interface PeerExchangeDiscoveryOptions {
/**
* Peer TTL in milliseconds.
* This is the time after which a peer will be considered stale and will be re-queried via peer exchange.
*
* @default 30_000
*/
TTL: number;
}
export declare class PeerExchangeDiscovery extends TypedEventEmitter<PeerDiscoveryEvents> implements PeerDiscovery {
private readonly components;
private readonly peerExchange;
private readonly options;
private isStarted;
private queryingPeers;
private peerExpirationRecords;
private continuousDiscoveryInterval;
constructor(components: Libp2pComponents, options?: Partial<PeerExchangeDiscoveryOptions>);
/**
* Start Peer Exchange.
* Subscribe to "peer:identify" events and handle them.
*/
start(): void;
/**
* Stop Peer Exchange.
* Unsubscribe from "peer:identify" events.
*/
stop(): void;
get [symbol](): true;
get [Symbol.toStringTag](): string;
private handleDiscoveredPeer;
private handlePeriodicDiscovery;
private runQuery;
private query;
private hasShardInfo;
}
export declare function wakuPeerExchangeDiscovery(options?: Partial<PeerExchangeDiscoveryOptions>): (components: Libp2pComponents) => PeerExchangeDiscovery;
export {};