Skip to content

Commit 2c97221

Browse files
authoredApr 23, 2020
chore: remove peer-info from api (#34)
* chore: remove peer-info from api BREAKING CHANGE: findProviders returns id and addrs properties instead of peer-info instance * chore: address review
1 parent 437c05e commit 2c97221

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const routing = new DelegatedContentRouing(peerId, {
3030
})
3131
const cid = new CID('QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv')
3232

33-
for await (const peerInfo of routing.findProviders(cid)) {
34-
console.log('found peer', peerInfo)
33+
for await (const { id, multiaddrs } of routing.findProviders(cid)) {
34+
console.log('found peer', id, multiaddrs)
3535
}
3636

3737
await routing.provide(cid)

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
"it-all": "^1.0.0",
3535
"multiaddr": "^7.4.3",
3636
"p-defer": "^3.0.0",
37-
"p-queue": "^6.3.0",
38-
"peer-info": "^0.17.5"
37+
"p-queue": "^6.2.1"
3938
},
4039
"contributors": [
4140
"Jacob Heun <jacobheun@gmail.com>",

‎src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const debug = require('debug')
44
const PeerId = require('peer-id')
5-
const PeerInfo = require('peer-info')
65
const createFindProvs = require('ipfs-http-client/src/dht/find-provs')
76
const createRefs = require('ipfs-http-client/src/refs')
87

@@ -63,7 +62,7 @@ class DelegatedContentRouting {
6362
* @param {object} options
6463
* @param {number} options.timeout How long the query can take. Defaults to 30 seconds
6564
* @param {number} options.numProviders How many providers to find, defaults to 20
66-
* @returns {AsyncIterable<PeerInfo>}
65+
* @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>}
6766
*/
6867
async * findProviders (key, options = {}) {
6968
const keyString = `${key}`
@@ -85,9 +84,10 @@ class DelegatedContentRouting {
8584
numProviders: options.numProviders,
8685
timeout: options.timeout
8786
})) {
88-
const peerInfo = new PeerInfo(PeerId.createFromCID(id))
89-
addrs.forEach(addr => peerInfo.multiaddrs.add(addr))
90-
yield peerInfo
87+
yield {
88+
id: PeerId.createFromCID(id),
89+
multiaddrs: addrs
90+
}
9191
}
9292
} catch (err) {
9393
log.error('findProviders errored:', err)

0 commit comments

Comments
 (0)
Please sign in to comment.