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

Commit

Permalink
Merge pull request #380 from ipfs/feat/swarm-interface-update
Browse files Browse the repository at this point in the history
feat(swarm): make interface-ipfs-core compliant
  • Loading branch information
dignifiedquire authored Sep 15, 2016
2 parents 0c8cbdc + 51f2402 commit 486fb1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"multiaddr": "^2.0.2",
"multipart-stream": "^2.0.1",
"ndjson": "^1.4.3",
"peer-id": "^0.7.0",
"peer-info": "^0.7.1",
"promisify-es6": "^1.0.1",
"qs": "^6.2.1",
"streamifier": "^0.1.1",
"tar-stream": "^1.5.2",
"wreck": "^10.0.0",
"streamifier": "^0.1.1"
"wreck": "^10.0.0"
},
"engines": {
"node": ">=4.2.2"
Expand All @@ -49,7 +51,7 @@
"chai": "^3.5.0",
"gulp": "^3.9.1",
"hapi": "^15.0.2",
"interface-ipfs-core": "^0.14.5",
"interface-ipfs-core": "^0.15.0",
"ipfsd-ctl": "^0.14.0",
"pre-commit": "^1.1.3",
"socket.io": "^1.4.8",
Expand Down Expand Up @@ -100,4 +102,4 @@
"url": "https://github.com/ipfs/js-ipfs-api/issues"
},
"homepage": "https://github.com/ipfs/js-ipfs-api"
}
}
16 changes: 12 additions & 4 deletions src/api/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const promisify = require('promisify-es6')
const multiaddr = require('multiaddr')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')

module.exports = (send) => {
return {
Expand Down Expand Up @@ -56,11 +58,17 @@ module.exports = (send) => {
if (err) {
return callback(err)
}
callback(null, Object.keys(result.Addrs).map((id) => {
return result.Addrs[id].map((maStr) => {
return multiaddr(maStr).encapsulate('/ipfs/' + id)

const peers = Object.keys(result.Addrs).map((id) => {
const info = new PeerInfo(PeerId.createFromB58String(id))
result.Addrs[id].forEach((addr) => {
info.multiaddr.add(multiaddr(addr))
})
})[0])

return info
})

callback(null, peers)
})
}),
localAddrs: promisify((opts, callback) => {
Expand Down

0 comments on commit 486fb1f

Please sign in to comment.