import { Message } from './message/index.js'; import { EventEmitter } from '@libp2p/interfaces/events'; import type { PeerId } from '@libp2p/interface-peer-id'; import type { AbortOptions } from '@libp2p/interfaces'; import type { Startable } from '@libp2p/interfaces/startable'; import type { Duplex } from 'it-stream-types'; import type { PeerInfo } from '@libp2p/interface-peer-info'; import { Components, Initializable } from '@libp2p/components'; import type { Uint8ArrayList } from 'uint8arraylist'; export interface NetworkInit { protocol: string; lan: boolean; } interface NetworkEvents { 'peer': CustomEvent; } /** * Handle network operations for the dht */ export declare class Network extends EventEmitter implements Startable, Initializable { private readonly log; private readonly protocol; private running; private components; /** * Create a new network */ constructor(init: NetworkInit); init(components: Components): void; /** * Start the network */ start(): Promise; /** * Stop all network activity */ stop(): Promise; /** * Is the network online? */ isStarted(): boolean; /** * Send a request and record RTT for latency measurements */ sendRequest(to: PeerId, msg: Message, options?: AbortOptions): AsyncGenerator; /** * Sends a message without expecting an answer */ sendMessage(to: PeerId, msg: Message, options?: AbortOptions): AsyncGenerator; /** * Write a message to the given stream */ _writeMessage(stream: Duplex, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise; /** * Write a message and read its response. * If no response is received after the specified timeout * this will error out. */ _writeReadMessage(stream: Duplex, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise; } export {}; //# sourceMappingURL=network.d.ts.map