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

swarm - move isConnected filter from addrs to peers #901

Merged
merged 1 commit into from
Jul 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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