File tree 3 files changed +8
-9
lines changed
3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ const routing = new DelegatedContentRouing(peerId, {
30
30
})
31
31
const cid = new CID (' QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv' )
32
32
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 )
35
35
}
36
36
37
37
await routing .provide (cid)
Original file line number Diff line number Diff line change 34
34
"it-all" : " ^1.0.0" ,
35
35
"multiaddr" : " ^7.4.3" ,
36
36
"p-defer" : " ^3.0.0" ,
37
- "p-queue" : " ^6.3.0" ,
38
- "peer-info" : " ^0.17.5"
37
+ "p-queue" : " ^6.2.1"
39
38
},
40
39
"contributors" : [
41
40
" Jacob Heun <jacobheun@gmail.com>" ,
Original file line number Diff line number Diff line change 2
2
3
3
const debug = require ( 'debug' )
4
4
const PeerId = require ( 'peer-id' )
5
- const PeerInfo = require ( 'peer-info' )
6
5
const createFindProvs = require ( 'ipfs-http-client/src/dht/find-provs' )
7
6
const createRefs = require ( 'ipfs-http-client/src/refs' )
8
7
@@ -63,7 +62,7 @@ class DelegatedContentRouting {
63
62
* @param {object } options
64
63
* @param {number } options.timeout How long the query can take. Defaults to 30 seconds
65
64
* @param {number } options.numProviders How many providers to find, defaults to 20
66
- * @returns {AsyncIterable<PeerInfo > }
65
+ * @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] } > }
67
66
*/
68
67
async * findProviders ( key , options = { } ) {
69
68
const keyString = `${ key } `
@@ -85,9 +84,10 @@ class DelegatedContentRouting {
85
84
numProviders : options . numProviders ,
86
85
timeout : options . timeout
87
86
} ) ) {
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
+ }
91
91
}
92
92
} catch ( err ) {
93
93
log . error ( 'findProviders errored:' , err )
You can’t perform that action at this time.
0 commit comments