Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Jacob Heun <[email protected]>
  • Loading branch information
vasco-santos and jacobheun committed Apr 16, 2020
1 parent e4d4016 commit c46dd73
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/topology/multicodec-topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ class MulticodecTopology extends Topology {

/**
* Update topology.
* @param {Array<{id: PeerId, multiaddrs: Array<Multiaddr>}>} peerDataIterable
* @param {Array<{id: PeerId, multiaddrs: Array<Multiaddr>, protocols: Array<string>}>} peerDataIterable
* @returns {void}
*/
_updatePeers (peerDataIterable) {
for (const peerData of peerDataIterable) {
if (this.multicodecs.filter(multicodec => peerData.protocols.includes(multicodec)).length) {
for (const { id, protocols } of peerDataIterable) {
if (this.multicodecs.filter(multicodec => protocols.includes(multicodec)).length) {
// Add the peer regardless of whether or not there is currently a connection
this.peers.add(peerData.id.toB58String())
this.peers.add(id.toB58String())
// If there is a connection, call _onConnect
const connection = this._registrar.getConnection(peerData.id)
connection && this._onConnect(peerData.id, connection)
const connection = this._registrar.getConnection(id)
connection && this._onConnect(id, connection)
} else {
// Remove any peers we might be tracking that are no longer of value to us
this.peers.delete(peerData.id.toB58String())
this.peers.delete(id.toB58String())
}
}
}
Expand Down

0 comments on commit c46dd73

Please sign in to comment.