You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Where `peerId` is a IPFS/libp2p Id from [PeerId](https://github.com/libp2p/js-peer-id) type.
19
19
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.
20
+
`callback` must follow `function (err, peerInfos) {}` signature, where `err` is an error if the operation was not successful. `peerInfos` is an array of type `[PeerInfo]`. In this case, as we are looking for a particular peer, there will be only one entry. This entry is composed by the peerId, as well as its adresses.
21
21
22
22
If no `callback` is passed, a promise is returned.
23
23
@@ -26,10 +26,10 @@ If no `callback` is passed, a promise is returned.
26
26
```JavaScript
27
27
var id =PeerId.create()
28
28
29
-
ipfs.dht.findpeer(id, function (err, res) {
30
-
//peerInfo will contain the multiaddrs of that peer
31
-
constid=res.responses[0].id
32
-
constaddrs=res.responses[0].addrs
29
+
ipfs.dht.findPeer(id, function (err, peerInfos) {
30
+
//peerInfos will contain the multiaddrs of that peer in the first entry of the array
31
+
constid=peerInfos[0].id
32
+
constaddrs=peerInfos[0].multiaddrs
33
33
})
34
34
```
35
35
@@ -41,23 +41,23 @@ A great source of [examples][] can be found in the tests for this API.
`options` an optional object with the following properties
49
49
-`timeout` - a maximum timeout in milliseconds
50
50
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.
51
+
`callback` must follow `function (err, peerInfos) {}` signature, where `err` is an error if the operation was not successful. `peerInfos` is an array of type `[PeerInfo]`. Each entry of this array is composed by the peerId, as well as an array with its adresses.
52
52
53
53
If no `callback` is passed, a promise is returned.
54
54
55
55
**Example:**
56
56
57
57
```JavaScript
58
-
ipfs.dht.findprovs(multihash, function (err, res) {})
58
+
ipfs.dht.findProvs(multihash, function (err, res) {})
59
59
60
-
ipfs.dht.findprovs(multihash, { timeout:4000 }, function (err, res) {})
60
+
ipfs.dht.findProvs(multihash, { timeout:4000 }, function (err, res) {})
61
61
```
62
62
63
63
A great source of [examples][] can be found in the tests for this API.
0 commit comments