mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-13 01:01:23 +00:00
fix: remove unneeded peerbook puts (#348)
This commit is contained in:
14
src/index.js
14
src/index.js
@ -78,7 +78,6 @@ class Node extends EventEmitter {
|
||||
// reuse this muxed connection
|
||||
this._switch.on('peer-mux-established', (peerInfo) => {
|
||||
this.emit('peer:connect', peerInfo)
|
||||
this.peerBook.put(peerInfo)
|
||||
})
|
||||
|
||||
this._switch.on('peer-mux-closed', (peerInfo) => {
|
||||
@ -244,11 +243,7 @@ class Node extends EventEmitter {
|
||||
this._getPeerInfo(peer, (err, peerInfo) => {
|
||||
if (err) { return callback(err) }
|
||||
|
||||
this._switch.dial(peerInfo, protocol, (err, conn) => {
|
||||
if (err) { return callback(err) }
|
||||
this.peerBook.put(peerInfo)
|
||||
callback(null, conn)
|
||||
})
|
||||
this._switch.dial(peerInfo, protocol, callback)
|
||||
})
|
||||
}
|
||||
|
||||
@ -274,12 +269,7 @@ class Node extends EventEmitter {
|
||||
this._getPeerInfo(peer, (err, peerInfo) => {
|
||||
if (err) { return callback(err) }
|
||||
|
||||
this._switch.dialFSM(peerInfo, protocol, (err, connFSM) => {
|
||||
if (!err) {
|
||||
this.peerBook.put(peerInfo)
|
||||
}
|
||||
callback(err, connFSM)
|
||||
})
|
||||
this._switch.dialFSM(peerInfo, protocol, callback)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user