Skip to content

Commit d1f0ec0

Browse files
committed
fix: extract peerIds from Multiaddrs for pendingDials function (libp2p#1567)
1 parent 6a2b8b9 commit d1f0ec0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/connection-manager/dialer/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type { AddressSorter, PeerStore } from '@libp2p/interface-peer-store'
2323
import type { Metrics } from '@libp2p/interface-metrics'
2424
import type { Dialer } from '@libp2p/interface-connection-manager'
2525
import type { TransportManager } from '@libp2p/interface-transport'
26+
import { peerIdFromString } from '@libp2p/peer-id'
2627

2728
const log = logger('libp2p:dialer')
2829

@@ -228,6 +229,10 @@ export class DefaultDialer implements Startable, Dialer {
228229
* Returns true if the peer id is in the pending dials
229230
*/
230231
hasPendingDial (peerId: PeerId | Multiaddr): boolean {
232+
if (isMultiaddr(peerId)) {
233+
return this.pendingDials.has(peerId.getPeerId() ?? '')
234+
}
235+
231236
return this.pendingDials.has(peerId.toString())
232237
}
233238

0 commit comments

Comments
 (0)