fix: remove unneeded peerbook puts (#348)

This commit is contained in:
Jacob Heun
2019-04-05 14:27:35 +02:00
committed by GitHub
parent 5204da73f7
commit e5f19e860b
5 changed files with 101 additions and 48 deletions

View File

@ -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)
})
}