Skip to content

Commit

Permalink
fix: extract peerIds from Multiaddrs for pendingDials function (#1567)
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Feb 15, 2023
1 parent 6a2b8b9 commit d1f0ec0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/connection-manager/dialer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { AddressSorter, PeerStore } from '@libp2p/interface-peer-store'
import type { Metrics } from '@libp2p/interface-metrics'
import type { Dialer } from '@libp2p/interface-connection-manager'
import type { TransportManager } from '@libp2p/interface-transport'
import { peerIdFromString } from '@libp2p/peer-id'

const log = logger('libp2p:dialer')

Expand Down Expand Up @@ -228,6 +229,10 @@ export class DefaultDialer implements Startable, Dialer {
* 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())
}

Expand Down

0 comments on commit d1f0ec0

Please sign in to comment.