Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 886ddd1

Browse files
committed
docs: updated spec
1 parent 685ba00 commit 886ddd1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

SPEC/DHT.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
##### `JavaScript` - ipfs.dht.findpeer(peerId, [callback])
1717

18-
Where `peerId` is a IPFS/libp2p Id of type [PeerId](https://github.com/libp2p/js-peer-id).
18+
Where `peerId` is a IPFS/libp2p Id from [PeerId](https://github.com/libp2p/js-peer-id) type.
1919

20-
`callback` must follow `function (err, peerInfo) {}` signature, where `err` is an error if the operation was not successful. `peerInfo` is an object of type [PeerInfo](https://github.com/libp2p/js-peer-info)
20+
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` is an object containing `responses` as an array of peer responses. In this case, as we are looking for a particular peer, there will be only one response. This response is composed by the peerId, as well as an array with its adresses.
2121

2222
If no `callback` is passed, a promise is returned.
2323

@@ -26,8 +26,10 @@ If no `callback` is passed, a promise is returned.
2626
```JavaScript
2727
var id = PeerId.create()
2828

29-
ipfs.dht.findpeer(id, function (err, peerInfo) {
29+
ipfs.dht.findpeer(id, function (err, res) {
3030
// peerInfo will contain the multiaddrs of that peer
31+
const id = res.responses[0].id
32+
const addrs = res.responses[0].addrs
3133
})
3234
```
3335

@@ -46,16 +48,16 @@ Where `hash` is a multihash.
4648
`options` an optional object with the following properties
4749
- `timeout` - a maximum timeout in milliseconds
4850

49-
`callback` must follow `function (err, peerInfos) {}` signature, where `err` is an error if the operation was not successful. `peerInfos` is an array of objects of type [PeerInfo](https://github.com/libp2p/js-peer-info)
51+
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` is an object containing `responses` as an array of peer responses. Each entry of this array is composed by the peerId, as well as an array with its adresses.
5052

5153
If no `callback` is passed, a promise is returned.
5254

5355
**Example:**
5456

5557
```JavaScript
56-
ipfs.dht.findprovs(multihash, function (err, peerInfos) {})
58+
ipfs.dht.findprovs(multihash, function (err, res) {})
5759

58-
ipfs.dht.findprovs(multihash, { timeout: 4000 }, function (err, peerInfos) {})
60+
ipfs.dht.findprovs(multihash, { timeout: 4000 }, function (err, res) {})
5961
```
6062

6163
A great source of [examples][] can be found in the tests for this API.

0 commit comments

Comments
 (0)