From 109a94d46c22163d9531666c9df14fc790401f52 Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 9 Aug 2016 08:34:42 +0100 Subject: [PATCH] feat(dht): add dht.put + .query spec --- API/dht/README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/API/dht/README.md b/API/dht/README.md index 27b44e85..afabcf9b 100644 --- a/API/dht/README.md +++ b/API/dht/README.md @@ -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) { +}) +```