Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat(dht): add dht.put + .query spec
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored and victorb committed Nov 8, 2016
1 parent 9ec3064 commit 841c2c3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions API/dht/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,37 @@ ipfs.dht.get(key, function (err, value) {})

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

Where `key` is a string and `value` can be of any type.

`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.

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

Example:

```JavaScript
ipfs.dht.put(key, value, function (err) {})
```


#### `query`

>
> Queries the network for the 'closest peers' to a given key. 'closest' is defined by the rules of the underlying Peer Routing mechanism.
##### `Go` **WIP**

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

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

`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)

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

Example:


```JavaScript
var id = PeerId.create()
ipfs.dht.query(id, function (err, peerInfos) {
})
```

0 comments on commit 841c2c3

Please sign in to comment.