Hierarchy

Implements

Constructors

  • Returns waku.ConnectionManager

Properties

#private: any
attemptDnsDiscovery: any
configuredPubsubTopics: string[]
currentActiveParallelDialCount: any
dialAttemptsForPeer: any
dialErrorsForPeer: any
dialPeerStorePeers: any
dispatchDiscoveryEvent: any
dispatchWakuConnectionEvent: any
getDialablePeerInfo: any

Internal utility to extract a PeerId or Multiaddr from a peer input. This is used internally by the connection manager to handle different peer input formats.

getPeerShardInfo: any
getTagNamesForPeer: any

Fetches the tag names for a given peer

isP2PNetworkConnected: any
isPeerDialableBasedOnBootstrapStatus: any

Checks if the peer is dialable based on the following conditions:

  1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.
  2. If the peer is not a bootstrap peer
isPeerTopicConfigured: any
keepAliveManager: any
libp2p: any
onEventHandlers: any
options: any
pendingPeerDialQueue: any
processDialQueue: any
setP2PNetworkConnected: any
setP2PNetworkDisconnected: any
shouldDialPeer: any

Checks if the peer should be dialed based on the following conditions:

  1. If the peer is already connected, don't dial
  2. If the peer is not part of any of the configured pubsub topics, don't dial
  3. If the peer is not dialable based on bootstrap status, don't dial
  4. If the peer is already has an active dial attempt, or has been dialed before, don't dial it

Returns

true if the peer should be dialed, false otherwise

startEventListeners: any
startNetworkStatusListener: any
startPeerConnectionListener: any
startPeerDisconnectionListener: any
startPeerDiscoveryListener: any
stopNetworkStatusListener: any
instances: any

Methods

  • Parameters

    • peerId: PeerId

    Returns Promise<void>

  • Attempts to establish a connection with a peer and set up specified protocols. The method handles both PeerId and Multiaddr inputs, manages connection attempts, and maintains the connection state.

    The dialing process includes:

    1. Converting input to dialable peer info
    2. Managing parallel dial attempts
    3. Attempting to establish protocol-specific connections
    4. Handling connection failures and retries
    5. Updating the peer store and connection state

    Parameters

    • peer: PeerId | MultiaddrInput

      The peer to connect to, either as a PeerId or multiaddr

    Returns Promise<Connection>

    Throws

    If the multiaddr is missing a peer ID

    Throws

    If the maximum dial attempts are reached and the peer cannot be dialed

    Throws

    If there's an error deleting an undialable peer from the peer store

    Example

    // Dial using PeerId
    await connectionManager.dialPeer(peerId);

    // Dial using multiaddr with specific protocols
    await connectionManager.dialPeer(multiaddr, [
    "/vac/waku/relay/2.0.0",
    "/vac/waku/lightpush/2.0.0-beta1"
    ]);

    Remarks

    • The method implements exponential backoff through multiple dial attempts
    • Maintains a queue for parallel dial attempts (limited by maxParallelDials)
    • Integrates with the KeepAliveManager for connection maintenance
    • Updates the peer store and connection state after successful/failed attempts
    • If all dial attempts fail, triggers DNS discovery as a fallback
  • Parameters

    • event: Event

    Returns boolean

  • Parameters

    • peerId: PeerId

    Returns Promise<void>

  • Returns boolean

  • Parameters

    • type: string

    Returns number

  • Dial a peer with specific protocols. This method is a raw proxy to the libp2p dialProtocol method.

    Parameters

    • peer: PeerId | MultiaddrInput

      The peer to connect to, either as a PeerId or multiaddr

    • protocolCodecs: string[]

      Optional array of protocol-specific codec strings to establish

    Returns Promise<Stream>

    A stream to the peer

  • Type Parameters

    • Detail

    Parameters

    Returns boolean

  • Returns void