1
1
# js-libp2p-delegated-content-routing
2
2
3
+ [ ![ ] ( https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square )] ( http://protocol.ai )
4
+ [ ![ ] ( https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square )] ( http://libp2p.io/ )
5
+ [ ![ ] ( https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square )] ( http://webchat.freenode.net/?channels=%23libp2p )
6
+ [ ![ Discourse posts] ( https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg )] ( https://discuss.libp2p.io )
7
+ [ ![ ] ( https://img.shields.io/codecov/c/github/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square )] ( https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing )
8
+ [ ![ ] ( https://img.shields.io/travis/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square )] ( https://travis-ci.com/libp2p/js-libp2p-delegated-content-routing )
9
+ [ ![ Dependency Status] ( https://david-dm.org/libp2p/js-libp2p-delegated-content-routing.svg?style=flat-square )] ( https://david-dm.org/libp2p/js-libp2p-delegated-content-routing )
10
+
3
11
Leverage other peers in the network to perform Content Routing calls.
4
12
5
13
## Lead Maintainer
@@ -18,22 +26,14 @@ const routing = new DelegatedContentRouing(peerId, {
18
26
port: 443 ,
19
27
host: ' ipfs.io'
20
28
})
29
+ const cid = new CID (' QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv' )
21
30
22
- routing .findProviders (key, (err , peerInfos ) => {
23
- if (err) {
24
- return console .error (err)
25
- }
26
-
27
- console .log (' found peers' , peerInfos)
28
- })
31
+ for await (const peerInfo of routing .findProviders (cid)) {
32
+ console .log (' found peer' , peerInfo)
33
+ }
29
34
30
- routing .provide (key, (err ) => {
31
- if (err) {
32
- return console .error (err)
33
- }
34
-
35
- console .log (' providing %s' , key)
36
- })
35
+ await routing .provide (cid)
36
+ console .log (' providing %s' , cid .toBaseEncodedString ())
37
37
```
38
38
39
39
## License
0 commit comments