The ConnectionManager handles managing connections between peers in a libp2p network. It provides methods for opening, closing, and querying connections.This also provides methods for accessing the dial queue.

interface ConnectionManager {
    acceptIncomingConnection(maConn): Promise<boolean>;
    afterUpgradeInbound(): void;
    closeConnections(peer, options?): Promise<void>;
    getConnections(peerId?): Connection[];
    getConnectionsMap(): PeerMap<Connection[]>;
    getDialQueue(): PendingDial[];
    getMaxConnections(): number;
    isDialable(multiaddr, options?): Promise<boolean>;
    openConnection(peer, options?): Promise<Connection>;
}

Methods

  • Invoked after an incoming connection is opened but before PeerIds are exchanged, this lets the ConnectionManager check we have sufficient resources to accept the connection in which case it will return true, otherwise it will return false.

    Parameters

    Returns Promise<boolean>

    A promise that resolves to true if the connection can be accepted, false otherwise.

  • Given the current node configuration, returns a promise of true or false if the node would attempt to dial the passed multiaddr.

    This means a relevant transport is configured, and the connection gater would not block the dial attempt.

    This may involve resolving DNS addresses so you should pass an AbortSignal.

    Parameters

    Returns Promise<boolean>

    A promise that resolves to true if the multiaddr is dialable, false otherwise.