libp2p
Version:
JavaScript implementation of libp2p, a modular peer to peer network stack
59 lines • 1.95 kB
TypeScript
import { serviceCapabilities } from '@libp2p/interface';
import type { ComponentLogger, Metrics, Startable } from '@libp2p/interface';
import type { ConnectionManager } from '@libp2p/interface-internal';
import type { AdaptiveTimeoutInit } from '@libp2p/utils/adaptive-timeout';
export interface ConnectionMonitorInit {
/**
* Whether the connection monitor is enabled
*
* @default true
*/
enabled?: boolean;
/**
* How often to ping remote peers in ms
*
* @default 10000
*/
pingInterval?: number;
/**
* Timeout settings for how long the ping is allowed to take before the
* connection will be judged inactive and aborted.
*
* The timeout is adaptive to cope with slower networks or nodes that
* have changing network characteristics, such as mobile.
*/
pingTimeout?: Omit<AdaptiveTimeoutInit, 'metricsName' | 'metrics'>;
/**
* If true, any connection that fails the ping will be aborted
*
* @default true
*/
abortConnectionOnPingFailure?: boolean;
/**
* Override the ping protocol prefix
*
* @default 'ipfs'
*/
protocolPrefix?: string;
}
export interface ConnectionMonitorComponents {
logger: ComponentLogger;
connectionManager: ConnectionManager;
metrics?: Metrics;
}
export declare class ConnectionMonitor implements Startable {
private readonly protocol;
private readonly components;
private readonly log;
private heartbeatInterval?;
private readonly pingIntervalMs;
private abortController?;
private readonly timeout;
private readonly abortConnectionOnPingFailure;
constructor(components: ConnectionMonitorComponents, init?: ConnectionMonitorInit);
readonly [Symbol.toStringTag] = "@libp2p/connection-monitor";
readonly [serviceCapabilities]: string[];
start(): void;
stop(): void;
}
//# sourceMappingURL=connection-monitor.d.ts.map