From c46dd732b51295ad2c97b7022bc7205c98ff1486 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 16 Apr 2020 17:24:32 +0200 Subject: [PATCH] chore: apply suggestions from code review Co-Authored-By: Jacob Heun --- src/topology/multicodec-topology.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/topology/multicodec-topology.js b/src/topology/multicodec-topology.js index 268d88a79..3e1406aeb 100644 --- a/src/topology/multicodec-topology.js +++ b/src/topology/multicodec-topology.js @@ -55,20 +55,20 @@ class MulticodecTopology extends Topology { /** * Update topology. - * @param {Array<{id: PeerId, multiaddrs: Array}>} peerDataIterable + * @param {Array<{id: PeerId, multiaddrs: Array, protocols: Array}>} 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()) } } }