Skip to content

Commit 1a3d47d

Browse files
authoredNov 10, 2020
chore: update readme with query endpoint for closest peers (#42)
* chore: update readme with query endpoint for closest peers * chore: update peerId dep
1 parent 5c3fb76 commit 1a3d47d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Leverage other peers in the network to perform Peer Routing calls.
44

5-
Requires access to `/api/v0/dht/findpeer` HTTP API endpoint of the delegate node.
5+
Requires access to `/api/v0/dht/findpeer` and `/api/v0/dht/query` HTTP API endpoints of the delegate node.
66

77
## Lead Maintainer
88

@@ -19,6 +19,7 @@ npm install ipfs-http-client libp2p-delegated-peer-routing
1919
## Example
2020

2121
```js
22+
const PeerId = require('peer-id')
2223
const DelegatedPeerRouting = require('libp2p-delegated-peer-routing')
2324
const ipfsHttpClient = require('ipfs-http-client')
2425

@@ -37,6 +38,12 @@ try {
3738
} catch (err) {
3839
console.error(err)
3940
}
41+
42+
const peerId = await PeerId.create({ keyType: 'ed25519' })
43+
for await (const { id, multiaddrs } of routing.getClosestPeers(peerId.id)) {
44+
console.log('found closest peer', id, multiaddrs)
45+
}
46+
4047
```
4148

4249
## License

0 commit comments

Comments
 (0)
Please sign in to comment.