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

Commit

Permalink
fix(swarm): move isConnected filter from addrs to peers (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis authored and dryajov committed Aug 31, 2017
1 parent 6270d90 commit 6667f8a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/core/components/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ module.exports = function swarm (self) {
// TODO: return latency and streams when verbose is set
// we currently don't have this information

const peers = self._peerInfoBook.getAll()
const keys = Object.keys(peers)

const peerList = flatMap(keys, (id) => {
const peer = peers[id]
const peers = values(self._peerInfoBook.getAll())
.filter((peer) => peer.isConnected())

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

if (verbose) {
Expand All @@ -53,7 +51,6 @@ module.exports = function swarm (self) {
}

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

callback(null, peers)
}),
Expand Down

0 comments on commit 6667f8a

Please sign in to comment.