Skip to content
This repository has been archived by the owner on Mar 10, 2020. 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 committed Aug 9, 2016
1 parent fe1b4fe commit 109a94d
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 109a94d

Please sign in to comment.