Skip to content

Commit

Permalink
feat: not remove peer from peerBook on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Mar 30, 2017
1 parent 291e79f commit a4b41b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class Node extends EventEmitter {

this.swarm.on('peer-mux-closed', (peerInfo) => {
this.emit('peer:disconnect', peerInfo)
// TODO remove this line
this.peerBook.removeByB58String(peerInfo.id.toB58String())
})
}

Expand Down Expand Up @@ -163,13 +161,19 @@ class Node extends EventEmitter {

dial (peer, protocol, callback) {
assert(this.isOn(), OFFLINE_ERROR_MESSAGE)
const peerInfo = this._getPeerInfo(peer)

if (typeof protocol === 'function') {
callback = protocol
protocol = undefined
}

let peerInfo
try {
peerInfo = this._getPeerInfo(peer)
} catch (err) {
return callback(err)
}

this.swarm.dial(peerInfo, protocol, (err, conn) => {
if (err) {
return callback(err)
Expand All @@ -183,7 +187,6 @@ class Node extends EventEmitter {
assert(this.isOn(), OFFLINE_ERROR_MESSAGE)
const peerInfo = this._getPeerInfo(peer)

this.peerBook.removeByB58String(peerInfo.id.toB58String())
this.swarm.hangUp(peerInfo, callback)
}

Expand Down

0 comments on commit a4b41b0

Please sign in to comment.