Skip to content

Commit 0fb036c

Browse files
committed
fix: emit peer discovery for dht discovery
1 parent 26de739 commit 0fb036c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"libp2p-circuit": "~0.3.0",
7272
"libp2p-delegated-content-routing": "~0.2.2",
7373
"libp2p-delegated-peer-routing": "~0.2.2",
74-
"libp2p-kad-dht": "~0.11.1",
74+
"libp2p-kad-dht": "libp2p/js-libp2p-kad-dht#feat/emit-event-on-peer-connected",
7575
"libp2p-mdns": "~0.12.0",
7676
"libp2p-mplex": "~0.8.4",
7777
"libp2p-secio": "~0.10.1",

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,12 @@ class Node extends EventEmitter {
407407
// have to set started here because DHT requires libp2p is already started
408408
this._isStarted = true
409409
if (this._dht) {
410-
this._dht.start(cb)
410+
this._dht.start(() => {
411+
this._dht.on('peer', (peerInfo) => {
412+
this.emit('peer:discovery', peerInfo)
413+
})
414+
cb()
415+
})
411416
} else {
412417
cb()
413418
}

0 commit comments

Comments
 (0)