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 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.
19
19
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.
21
21
22
22
If no `callback` is passed, a promise is returned.
23
23
@@ -26,8 +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, peerInfo) {
29
+
ipfs.dht.findpeer(id, function (err, res) {
30
30
// peerInfo will contain the multiaddrs of that peer
31
+
constid=res.responses[0].id
32
+
constaddrs=res.responses[0].addrs
31
33
})
32
34
```
33
35
@@ -46,16 +48,16 @@ Where `hash` is a multihash.
46
48
`options` an optional object with the following properties
47
49
-`timeout` - a maximum timeout in milliseconds
48
50
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.
50
52
51
53
If no `callback` is passed, a promise is returned.
52
54
53
55
**Example:**
54
56
55
57
```JavaScript
56
-
ipfs.dht.findprovs(multihash, function (err, peerInfos) {})
58
+
ipfs.dht.findprovs(multihash, function (err, res) {})
57
59
58
-
ipfs.dht.findprovs(multihash, { timeout:4000 }, function (err, peerInfos) {})
60
+
ipfs.dht.findprovs(multihash, { timeout:4000 }, function (err, res) {})
59
61
```
60
62
61
63
A great source of [examples][] can be found in the tests for this API.
0 commit comments