Skip to content

Commit 45f1766

Browse files
committed
fix: emit peer discovery for dht discovery
1 parent ebaab3e commit 45f1766

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-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.14.2",
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.11.0",

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,10 @@ 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) => this.emit('peer:discovery', peerInfo))
412+
cb()
413+
})
411414
} else {
412415
cb()
413416
}

0 commit comments

Comments
 (0)