From 99911b19179815b5ee2ad4f11f3bd25c257012dd Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Thu, 2 Aug 2018 19:00:08 +0200 Subject: [PATCH] fix(dht): allow for options object in `findProvs()` API (#1457) 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) }), /**