chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos 2020-04-27 16:11:25 +02:00
parent fdf31c9bbb
commit fb5252f398
2 changed files with 2 additions and 7 deletions

View File

@ -1168,7 +1168,7 @@ unless they are performing a specific action. See [peer discovery and auto dial]
This event will be triggered anytime a new Connection is established to another peer.
`libp2p.on('peer:connect', (connection) => {})`
`libp2p.connectionManager.on('peer:connect', (connection) => {})`
- `connection`: instance of [`Connection`][connection]
@ -1176,7 +1176,7 @@ This event will be triggered anytime a new Connection is established to another
This event will be triggered anytime we are disconnected from another peer, regardless of the circumstances of that disconnection. If we happen to have multiple connections to a peer, this event will **only** be triggered when the last connection is closed.
`libp2p.on('peer:disconnect', (connection) => {})`
`libp2p.connectionManager.on('peer:disconnect', (connection) => {})`
- `connection`: instance of [`Connection`][connection]

View File

@ -9,7 +9,6 @@ const retimer = require('retimer')
const { EventEmitter } = require('events')
const PeerId = require('peer-id')
const { Connection } = require('libp2p-interfaces/src/connection')
const {
ERR_INVALID_PARAMETERS
@ -172,10 +171,6 @@ class ConnectionManager extends EventEmitter {
* @param {Connection} connection
*/
onConnect (connection) {
if (!Connection.isConnection(connection)) {
throw errcode(new Error('conn must be an instance of interface-connection'), ERR_INVALID_PARAMETERS)
}
const peerId = connection.remotePeer.toB58String()
const storedConn = this.connections.get(peerId)