mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
feat: not remove peer from peerBook on disconnect
This commit is contained in:
parent
291e79fc99
commit
a4b41b0f9a
11
src/index.js
11
src/index.js
@ -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())
|
||||
})
|
||||
}
|
||||
|
||||
@ -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)
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user