@libp2p/interface
Version:
The interface implemented by a libp2p node
53 lines • 1.54 kB
TypeScript
import type { Connection, Stream } from './connection.js';
import type { AbortOptions } from './index.ts';
export interface IncomingStreamData {
/**
* The newly opened stream
*/
stream: Stream;
/**
* The connection the stream was opened on
*/
connection: Connection;
}
export interface StreamHandler {
/**
* A callback function that accepts the incoming stream data
*/
(data: IncomingStreamData): void;
}
export interface StreamHandlerOptions extends AbortOptions {
/**
* How many incoming streams can be open for this protocol at the same time on each connection
*
* @default 32
*/
maxInboundStreams?: number;
/**
* How many outgoing streams can be open for this protocol at the same time on each connection
*
* @default 64
*/
maxOutboundStreams?: number;
/**
* Opt-in to running over connections with limits on how much data can be
* transferred or how long it can be open for.
*/
runOnLimitedConnection?: boolean;
/**
* If `true`, and a handler is already registered for the specified
* protocol(s), the existing handler will be discarded.
*/
force?: true;
}
export interface StreamHandlerRecord {
/**
* The handler that was registered to handle streams opened on the protocol
*/
handler: StreamHandler;
/**
* The options that were used to register the stream handler
*/
options: StreamHandlerOptions;
}
//# sourceMappingURL=stream-handler.d.ts.map