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

Commit 841c2c3

Browse files
daviddiasvictorb
authored andcommitted
feat(dht): add dht.put + .query spec
1 parent 9ec3064 commit 841c2c3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

API/dht/README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,37 @@ ipfs.dht.get(key, function (err, value) {})
7272

7373
##### `JavaScript` - ipfs.dht.put(key, value, [callback])
7474

75+
Where `key` is a string and `value` can be of any type.
76+
77+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
7578

7679
If no `callback` is passed, a promise is returned.
7780

7881
Example:
7982

83+
```JavaScript
84+
ipfs.dht.put(key, value, function (err) {})
85+
```
86+
8087

8188
#### `query`
8289

83-
>
90+
> Queries the network for the 'closest peers' to a given key. 'closest' is defined by the rules of the underlying Peer Routing mechanism.
8491
8592
##### `Go` **WIP**
8693

8794
##### `JavaScript` - ipfs.dht.query(peerId, [callback])
8895

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

98+
`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)
9099

91100
If no `callback` is passed, a promise is returned.
92101

93102
Example:
94103

95-
104+
```JavaScript
105+
var id = PeerId.create()
106+
ipfs.dht.query(id, function (err, peerInfos) {
107+
})
108+
```

0 commit comments

Comments
 (0)