From 75ac898c1e75e1db1c5e3afd011f32bdc242aafe Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Fri, 20 Jul 2018 15:45:48 +0200 Subject: [PATCH] fix(dht): allow for options object in `findProvs()` API This is to complement: https://github.com/ipfs/interface-ipfs-core/pull/337 Fixes #1322 --- src/core/components/dht.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/components/dht.js b/src/core/components/dht.js index 8504df7488..e5edf281db 100644 --- a/src/core/components/dht.js +++ b/src/core/components/dht.js @@ -56,12 +56,19 @@ module.exports = (self) => { * @param {function(Error, Array)} [callback] * @returns {Promise|void} */ - findprovs: promisify((key, callback) => { + findprovs: promisify((key, opts, callback) => { if (typeof key === 'string') { key = new CID(key) } - self._libp2pNode.contentRouting.findProviders(key, callback) + if (typeof opts === 'function') { + callback = opts + opts = {} + } + + opts = opts || {} + + self._libp2pNode.contentRouting.findProviders(key, opts.timeout || null, callback) }), /**