Skip to content

Commit

Permalink
fix: emit peer discovery for dht discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Dec 28, 2018
1 parent 26de739 commit 0fb036c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"libp2p-circuit": "~0.3.0",
"libp2p-delegated-content-routing": "~0.2.2",
"libp2p-delegated-peer-routing": "~0.2.2",
"libp2p-kad-dht": "~0.11.1",
"libp2p-kad-dht": "libp2p/js-libp2p-kad-dht#feat/emit-event-on-peer-connected",
"libp2p-mdns": "~0.12.0",
"libp2p-mplex": "~0.8.4",
"libp2p-secio": "~0.10.1",
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,12 @@ class Node extends EventEmitter {
// have to set started here because DHT requires libp2p is already started
this._isStarted = true
if (this._dht) {
this._dht.start(cb)
this._dht.start(() => {
this._dht.on('peer', (peerInfo) => {
this.emit('peer:discovery', peerInfo)
})
cb()
})
} else {
cb()
}
Expand Down

0 comments on commit 0fb036c

Please sign in to comment.