diff --git a/README.md b/README.md index 2feeae5..98734e6 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ const routing = new DelegatedContentRouing(peerId, { }) const cid = new CID('QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv') -for await (const peerInfo of routing.findProviders(cid)) { - console.log('found peer', peerInfo) +for await (const { id, multiaddrs } of routing.findProviders(cid)) { + console.log('found peer', id, multiaddrs) } await routing.provide(cid) diff --git a/package.json b/package.json index 496881a..2732f7a 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,7 @@ "it-all": "^1.0.0", "multiaddr": "^7.4.3", "p-defer": "^3.0.0", - "p-queue": "^6.3.0", - "peer-info": "^0.17.5" + "p-queue": "^6.2.1" }, "contributors": [ "Jacob Heun ", diff --git a/src/index.js b/src/index.js index 7f56d03..34c58c6 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,6 @@ const debug = require('debug') const PeerId = require('peer-id') -const PeerInfo = require('peer-info') const createFindProvs = require('ipfs-http-client/src/dht/find-provs') const createRefs = require('ipfs-http-client/src/refs') @@ -63,7 +62,7 @@ class DelegatedContentRouting { * @param {object} options * @param {number} options.timeout How long the query can take. Defaults to 30 seconds * @param {number} options.numProviders How many providers to find, defaults to 20 - * @returns {AsyncIterable} + * @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>} */ async * findProviders (key, options = {}) { const keyString = `${key}` @@ -85,9 +84,10 @@ class DelegatedContentRouting { numProviders: options.numProviders, timeout: options.timeout })) { - const peerInfo = new PeerInfo(PeerId.createFromCID(id)) - addrs.forEach(addr => peerInfo.multiaddrs.add(addr)) - yield peerInfo + yield { + id: PeerId.createFromCID(id), + multiaddrs: addrs + } } } catch (err) { log.error('findProviders errored:', err)