Skip to content

Commit

Permalink
feat: updated connection manager and dialer with new interface methods (
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Feb 16, 2023
1 parent cacb316 commit f6f73a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/connection-manager/dialer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ export class DefaultDialer implements Startable, Dialer {
}
}

/**
* Get the current dial targets which are pending
*/
getPendingDialTargets (): Map<string, AbortController> {
return this.pendingDialTargets
}

/**
* Returns true if the peer id is in the pending dials
*/
hasPendingDial (peerId: PeerId | Multiaddr): boolean {
if (isMultiaddr(peerId)) {
return this.pendingDials.has(peerId.getPeerId() ?? '')
}

return this.pendingDials.has(peerId.toString())
}

/**
* Creates a DialTarget. The DialTarget is used to create and track
* the DialRequest to a given peer.
Expand Down
4 changes: 4 additions & 0 deletions src/connection-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven
return conns
}

getConnectionsMap (): Map<string, Connection[]> {
return this.connections
}

async openConnection (peerIdOrMultiaddr: PeerId | Multiaddr, options: AbortOptions = {}): Promise<Connection> {
const { peerId, multiaddr } = getPeerAddress(peerIdOrMultiaddr)

Expand Down

0 comments on commit f6f73a2

Please sign in to comment.