Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed Apr 27, 2020
1 parent fdf31c9 commit fb5252f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,15 +1168,15 @@ 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]

#### An existing connection to a peer has been closed

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]

Expand Down
5 changes: 0 additions & 5 deletions src/connection-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit fb5252f

Please sign in to comment.