mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 18:02:28 +00:00
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
declare const _exports: MulticodecTopology;
|
|
export = _exports;
|
|
declare class MulticodecTopology {
|
|
/**
|
|
* @param {Object} props
|
|
* @param {number} props.min minimum needed connections (default: 0)
|
|
* @param {number} props.max maximum needed connections (default: Infinity)
|
|
* @param {Array<string>} props.multicodecs protocol multicodecs
|
|
* @param {Object} props.handlers
|
|
* @param {function} props.handlers.onConnect protocol "onConnect" handler
|
|
* @param {function} props.handlers.onDisconnect protocol "onDisconnect" handler
|
|
* @constructor
|
|
*/
|
|
constructor({ min, max, multicodecs, handlers }: {
|
|
min: number;
|
|
max: number;
|
|
multicodecs: string[];
|
|
handlers: {
|
|
onConnect: Function;
|
|
onDisconnect: Function;
|
|
};
|
|
});
|
|
multicodecs: string[];
|
|
_registrar: any;
|
|
/**
|
|
* Check if a new peer support the multicodecs for this topology.
|
|
* @param {Object} props
|
|
* @param {PeerId} props.peerId
|
|
* @param {Array<string>} props.protocols
|
|
*/
|
|
_onProtocolChange({ peerId, protocols }: {
|
|
peerId: any;
|
|
protocols: string[];
|
|
}): void;
|
|
/**
|
|
* Verify if a new connected peer has a topology multicodec and call _onConnect.
|
|
* @param {Connection} connection
|
|
* @returns {void}
|
|
*/
|
|
_onPeerConnect(connection: any): void;
|
|
set registrar(arg: any);
|
|
/**
|
|
* Update topology.
|
|
* @param {Array<{id: PeerId, multiaddrs: Array<Multiaddr>, protocols: Array<string>}>} peerDataIterable
|
|
* @returns {void}
|
|
*/
|
|
_updatePeers(peerDataIterable: {
|
|
id: any;
|
|
multiaddrs: any[];
|
|
protocols: string[];
|
|
}[]): void;
|
|
}
|