Skip to content

Commit acbf21f

Browse files
committed
feat: not remove peer from peerBook on disconnect
1 parent 291e79f commit acbf21f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class Node extends EventEmitter {
4848

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

@@ -163,7 +161,12 @@ class Node extends EventEmitter {
163161

164162
dial (peer, protocol, callback) {
165163
assert(this.isOn(), OFFLINE_ERROR_MESSAGE)
166-
const peerInfo = this._getPeerInfo(peer)
164+
let peerInfo
165+
try {
166+
peerInfo = this._getPeerInfo(peer)
167+
} catch (err) {
168+
return callback(err)
169+
}
167170

168171
if (typeof protocol === 'function') {
169172
callback = protocol

0 commit comments

Comments
 (0)