Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Only show connected addrs for peers in swarm.peers
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb committed Aug 26, 2017
1 parent a85cf70 commit e5857bf
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/core/components/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const multiaddr = require('multiaddr')
const promisify = require('promisify-es6')
const flatMap = require('lodash.flatmap')
const values = require('lodash.values')

const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR
Expand All @@ -24,24 +23,19 @@ module.exports = function swarm (self) {
// we currently don't have this information

const peers = values(self._peerInfoBook.getAll())
.filter((peer) => peer.isConnected())

const peerList = flatMap(peers, (peer) => {
return peer.multiaddrs.toArray().map((addr) => {
.map((peer) => {
const connectedAddr = peer.isConnected()
const res = {
addr: addr,
peer: peer
addr: connectedAddr,
peer
}

if (verbose) {
res.latency = 'unknown'
}

return res
})
})

callback(null, peerList)
callback(null, peers)
}),

// all the addrs we know
Expand Down

0 comments on commit e5857bf

Please sign in to comment.