@waku/discovery
Version:
Contains various discovery mechanisms: DNS Discovery (EIP-1459, Peer Exchange, Local Peer Cache Discovery.
59 lines (58 loc) • 2.08 kB
TypeScript
import { TypedEventEmitter } from "@libp2p/interface";
import { peerDiscoverySymbol as symbol } from "@libp2p/interface";
import type { PeerDiscovery, PeerDiscoveryEvents } from "@libp2p/interface";
import { type Libp2pComponents, Tags } from "@waku/interfaces";
export interface Options {
/**
* Tag a bootstrap peer with this name before "discovering" it (default: 'bootstrap')
*/
tagName?: string;
/**
* The bootstrap peer tag will have this value (default: 50)
*/
tagValue?: number;
/**
* Cause the bootstrap peer tag to be removed after this number of ms (default: 2 minutes)
*/
tagTTL?: number;
/**
* The interval between queries to a peer (default: 10 seconds)
* The interval will increase by a factor of an incrementing number (starting at 1)
* until it reaches the maximum attempts before backoff
*/
queryInterval?: number;
/**
* The number of attempts before the queries to a peer are aborted (default: 3)
*/
maxRetries?: number;
}
interface CustomDiscoveryEvent extends PeerDiscoveryEvents {
"waku:peer-exchange:started": CustomEvent<boolean>;
}
export declare const DEFAULT_PEER_EXCHANGE_TAG_NAME = Tags.PEER_EXCHANGE;
export declare class PeerExchangeDiscovery extends TypedEventEmitter<CustomDiscoveryEvent> implements PeerDiscovery {
private readonly components;
private readonly peerExchange;
private readonly options;
private isStarted;
private queryingPeers;
private queryAttempts;
private readonly handleDiscoveredPeer;
constructor(components: Libp2pComponents, options?: Options);
/**
* Start emitting events
*/
start(): void;
/**
* Remove event listener
*/
stop(): void;
get [symbol](): true;
get [Symbol.toStringTag](): string;
private readonly startRecurringQueries;
private query;
private abortQueriesForPeer;
private checkPeerInfoDiff;
}
export declare function wakuPeerExchangeDiscovery(): (components: Libp2pComponents) => PeerExchangeDiscovery;
export {};