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.
PrivategetPeerShardInfo
getPeerShardInfo:any
PrivategetTagNamesForPeer
getTagNamesForPeer:any
Fetches the tag names for a given peer
PrivateisP2PNetworkConnected
isP2PNetworkConnected:any
PrivateisPeerDialableBasedOnBootstrapStatus
isPeerDialableBasedOnBootstrapStatus:any
Checks if the peer is dialable based on the following conditions:
If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.
If the peer is not a bootstrap peer
PrivateisPeerTopicConfigured
isPeerTopicConfigured:any
PrivatekeepAliveManager
keepAliveManager:any
Privatelibp2p
libp2p:any
PrivateonEventHandlers
onEventHandlers:any
Privateoptions
options:any
PrivatependingPeerDialQueue
pendingPeerDialQueue:any
PrivateprocessDialQueue
processDialQueue:any
ReadonlypubsubTopics
pubsubTopics:string[]
PrivatesetP2PNetworkConnected
setP2PNetworkConnected:any
PrivatesetP2PNetworkDisconnected
setP2PNetworkDisconnected:any
PrivateshouldDialPeer
shouldDialPeer:any
Checks if the peer should be dialed based on the following conditions:
If the peer is already connected, don't dial
If the peer is not part of any of the configured pubsub topics, don't dial
If the peer is not dialable based on bootstrap status, don't dial
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
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:
Converting input to dialable peer info
Managing parallel dial attempts
Attempting to establish protocol-specific connections
Handling connection failures and retries
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 awaitconnectionManager.dialPeer(peerId);
// Dial using multiaddr with specific protocols awaitconnectionManager.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
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.