import { contentRoutingSymbol, peerDiscoverySymbol, peerRoutingSymbol, serviceCapabilities, serviceDependencies } from '@libp2p/interface'; import { TypedEventEmitter } from 'main-event'; import { Network } from './network.js'; import { PeerRouting as KADDHTPeerRouting } from './peer-routing/index.js'; import { Providers } from './providers.js'; import { RoutingTable } from './routing-table/index.js'; import type { KadDHTComponents, KadDHTInit, KadDHT as KadDHTInterface, QueryEvent, SetModeOptions } from './index.js'; import type { ContentRouting, CounterGroup, MetricGroup, PeerDiscovery, PeerDiscoveryEvents, PeerId, PeerInfo, PeerRouting, RoutingOptions, Startable } from '@libp2p/interface'; import type { AbortOptions } from 'it-pushable'; import type { CID } from 'multiformats/cid'; export declare const DEFAULT_MAX_INBOUND_STREAMS = 32; export declare const DEFAULT_MAX_OUTBOUND_STREAMS = 64; export type Operation = 'GET_VALUE' | 'FIND_PROVIDERS' | 'FIND_PEER' | 'GET_CLOSEST_PEERS' | 'PROVIDE' | 'PUT_VALUE' | 'SELF_QUERY'; export interface OperationMetrics { queries?: MetricGroup; errors?: CounterGroup; queryTime?: MetricGroup; errorTime?: MetricGroup; } /** * A DHT implementation modelled after Kademlia with S/Kademlia modifications. * Original implementation in go: https://github.com/libp2p/go-libp2p-kad-dht. */ export declare class KadDHT extends TypedEventEmitter implements KadDHTInterface, Startable { readonly k: number; readonly a: number; readonly d: number; protocol: string; routingTable: RoutingTable; providers: Providers; network: Network; peerRouting: KADDHTPeerRouting; readonly components: KadDHTComponents; private readonly log; private running; private clientMode; private readonly validators; private readonly selectors; private readonly queryManager; private readonly contentFetching; private readonly contentRouting; private readonly routingTableRefresh; private readonly rpc; private readonly topologyListener; private readonly querySelf; private readonly maxInboundStreams; private readonly maxOutboundStreams; private readonly dhtContentRouting; private readonly dhtPeerRouting; private readonly peerInfoMapper; private readonly reprovider; private readonly onPeerConnectTimeout; /** * Create a new KadDHT */ constructor(components: KadDHTComponents, init?: KadDHTInit); readonly [Symbol.toStringTag] = "@libp2p/kad-dht"; readonly [serviceCapabilities]: string[]; readonly [serviceDependencies]: string[]; get [contentRoutingSymbol](): ContentRouting; get [peerRoutingSymbol](): PeerRouting; get [peerDiscoverySymbol](): PeerDiscovery; onPeerConnect(peerData: PeerInfo): Promise; /** * Is this DHT running. */ isStarted(): boolean; /** * If 'server' this node will respond to DHT queries, if 'client' this node will not */ getMode(): 'client' | 'server'; /** * If 'server' this node will respond to DHT queries, if 'client' this node will not */ setMode(mode: 'client' | 'server', options?: SetModeOptions): Promise; /** * Start listening to incoming connections. */ start(): Promise; /** * Stop accepting incoming connections and sending outgoing * messages. */ stop(): Promise; /** * Store the given key/value pair in the DHT */ put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions): AsyncGenerator; /** * Get the value that corresponds to the passed key */ get(key: Uint8Array, options?: RoutingOptions): AsyncGenerator; /** * Announce to the network that we can provide given key's value */ provide(key: CID, options?: RoutingOptions): AsyncGenerator; /** * Provider records must be re-published every 24 hours - pass a previously * provided CID here to not re-publish a record for it any more */ cancelReprovide(key: CID, options?: AbortOptions): Promise; /** * Search the dht for providers of the given CID */ findProviders(key: CID, options?: RoutingOptions): AsyncGenerator; /** * Search for a peer with the given ID */ findPeer(id: PeerId, options?: RoutingOptions): AsyncGenerator; /** * Kademlia 'node lookup' operation */ getClosestPeers(key: Uint8Array, options?: RoutingOptions): AsyncGenerator; refreshRoutingTable(options?: AbortOptions): Promise; } //# sourceMappingURL=kad-dht.d.ts.map