Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
fix: result.Peers can be null, ensure callback is called
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw committed May 16, 2018
1 parent faa51b4 commit f5f2e83
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/swarm/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module.exports = (send) => {
return callback(err)
}

// go-ipfs <= 0.4.4
if (result.Strings) {
// go-ipfs <= 0.4.4
callback(null, result.Strings.map((p) => {
return callback(null, result.Strings.map((p) => {
const res = {}

if (verbose) {
Expand All @@ -40,26 +40,26 @@ module.exports = (send) => {

return res
}))
} else if (result.Peers) {
// go-ipfs >= 0.4.5
callback(null, result.Peers.map((p) => {
const res = {
addr: multiaddr(p.Addr),
peer: PeerId.createFromB58String(p.Peer),
muxer: p.Muxer
}
}

if (p.Latency) {
res.latency = p.Latency
}
// go-ipfs >= 0.4.5
callback(null, (result.Peers || []).map((p) => {
const res = {
addr: multiaddr(p.Addr),
peer: PeerId.createFromB58String(p.Peer),
muxer: p.Muxer
}

if (p.Streams) {
res.streams = p.Streams
}
if (p.Latency) {
res.latency = p.Latency
}

return res
}))
}
if (p.Streams) {
res.streams = p.Streams
}

return res
}))
})
})
}

0 comments on commit f5f2e83

Please sign in to comment.