import { TypedEventEmitter } from 'main-event'; import { Message } from './message/dht.js'; import type { DisjointPath, KadDHTComponents, QueryEvent } from './index.js'; import type { AbortOptions, Stream, PeerId, PeerInfo, Startable, RoutingOptions } from '@libp2p/interface'; import type { AdaptiveTimeoutInit } from '@libp2p/utils'; export interface NetworkInit { protocol: string; logPrefix: string; metricsPrefix: string; timeout?: Omit; } interface NetworkEvents { peer: CustomEvent; } export interface SendMessageOptions extends RoutingOptions { /** * Queries involve following up to `k` disjoint paths through the network - * this option is which index within `k` this message is for, and it * allows observers to collate events together on a per-path basis */ path: DisjointPath; } /** * Handle network operations for the dht */ export declare class Network extends TypedEventEmitter implements Startable { private readonly log; private readonly protocol; private running; private readonly components; private readonly timeout; private readonly metrics; /** * Create a new network */ constructor(components: KadDHTComponents, init: NetworkInit); /** * Start the network */ start(): Promise; /** * Stop all network activity */ stop(): Promise; /** * Is the network online? */ isStarted(): boolean; /** * Send a request and read a response */ sendRequest(to: PeerId, msg: Partial, options: SendMessageOptions): AsyncGenerator; /** * Sends a message without expecting an answer */ sendMessage(to: PeerId, msg: Partial, options: SendMessageOptions): AsyncGenerator; /** * Write a message to the given stream */ _writeMessage(stream: Stream, msg: Partial, options: AbortOptions): Promise; /** * Write a message and read a response */ _writeReadMessage(stream: Stream, msg: Partial, options: AbortOptions): Promise; } export {}; //# sourceMappingURL=network.d.ts.map