UNPKG

libp2p

Version:

JavaScript implementation of libp2p, a modular peer to peer network stack

84 lines 2.58 kB
import { connectionSymbol } from '@libp2p/interface'; import type { AbortOptions, Logger, ComponentLogger, Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions, PeerId, ConnectionLimits } from '@libp2p/interface'; import type { Multiaddr } from '@multiformats/multiaddr'; interface ConnectionInit { remoteAddr: Multiaddr; remotePeer: PeerId; newStream(protocols: string[], options?: AbortOptions): Promise<Stream>; close(options?: AbortOptions): Promise<void>; abort(err: Error): void; getStreams(): Stream[]; status: ConnectionStatus; direction: Direction; timeline: ConnectionTimeline; multiplexer?: string; encryption?: string; limits?: ConnectionLimits; logger: ComponentLogger; } /** * An implementation of the js-libp2p connection. * Any libp2p transport should use an upgrader to return this connection. */ export declare class ConnectionImpl implements Connection { /** * Connection identifier. */ readonly id: string; /** * Observed multiaddr of the remote peer */ readonly remoteAddr: Multiaddr; /** * Remote peer id */ readonly remotePeer: PeerId; direction: Direction; timeline: ConnectionTimeline; multiplexer?: string; encryption?: string; status: ConnectionStatus; limits?: ConnectionLimits; readonly log: Logger; /** * User provided tags * */ tags: string[]; /** * Reference to the new stream function of the multiplexer */ private readonly _newStream; /** * Reference to the close function of the raw connection */ private readonly _close; private readonly _abort; /** * Reference to the getStreams function of the muxer */ private readonly _getStreams; /** * An implementation of the js-libp2p connection. * Any libp2p transport should use an upgrader to return this connection. */ constructor(init: ConnectionInit); readonly [Symbol.toStringTag] = "Connection"; readonly [connectionSymbol] = true; /** * Get all the streams of the muxer */ get streams(): Stream[]; /** * Create a new stream from this connection */ newStream(protocols: string | string[], options?: NewStreamOptions): Promise<Stream>; /** * Close the connection */ close(options?: AbortOptions): Promise<void>; abort(err: Error): void; } export declare function createConnection(init: ConnectionInit): Connection; export {}; //# sourceMappingURL=index.d.ts.map