Skip to content

Commit

Permalink
feat: update events to conform with #74
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Mar 29, 2017
1 parent 8840c9b commit f73c045
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class Node extends EventEmitter {
// Received incommind dial and muxer upgrade happened, reuse this
// muxed connection
this.swarm.on('peer-mux-established', (peerInfo) => {
this.emit('peer:connect', peerInfo)
this.peerBook.put(peerInfo)
})

this.swarm.on('peer-mux-closed', (peerInfo) => {
this.emit('peer:disconnect', peerInfo)
this.peerBook.removeByB58String(peerInfo.id.toB58String())
})
}
Expand All @@ -62,8 +64,9 @@ class Node extends EventEmitter {
if (this.modules.discovery) {
let discoveries = this.modules.discovery
discoveries = Array.isArray(discoveries) ? discoveries : [discoveries]

discoveries.forEach((discovery) => {
discovery.on('peer', (peerInfo) => this.emit('peer', peerInfo))
discovery.on('peer', (peerInfo) => this.emit('peer:discovery', peerInfo))
})
}

Expand Down

0 comments on commit f73c045

Please sign in to comment.