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

Commit 0080f20

Browse files
committed
attempt to handle changes to ipfs swarm peers api
1 parent 1487d3e commit 0080f20

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/api/swarm.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,29 @@ module.exports = (send) => {
1212
callback = opts
1313
opts = {}
1414
}
15+
if (opts['v']) {
16+
throw "I don't know how to handle errors in javascript, but the -v option needs to be handled"
17+
}
1518
send({
1619
path: 'swarm/peers',
1720
qs: opts
1821
}, (err, result) => {
1922
if (err) {
2023
return callback(err)
2124
}
22-
callback(null, result.Strings.map((addr) => {
23-
return multiaddr(addr)
24-
}))
25+
if (result.Strings) {
26+
callback(null, result.Strings.map((addr) => {
27+
return multiaddr(addr)
28+
}))
29+
} else if (result.Peers) {
30+
let out = result.Peers.map((p) => {
31+
return {
32+
addr: new multiaddr(p.Addr),
33+
peer: new PeerId(p.Peer),
34+
latency: p.Latency,
35+
streams: p.Streams,
36+
}
37+
}
2538
})
2639
}),
2740
connect: promisify((args, opts, callback) => {

0 commit comments

Comments
 (0)