libp2p-kad-dht
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -0,1 +1,6 @@ | ||
<a name="0.11.1"></a> | ||
## [0.11.1](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.11.0...v0.11.1) (2018-11-12) | ||
<a name="0.11.0"></a> | ||
@@ -2,0 +7,0 @@ # [0.11.0](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.10.6...v0.11.0) (2018-11-09) |
{ | ||
"name": "libp2p-kad-dht", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "JavaScript implementation of the Kad-DHT for libp2p", | ||
@@ -5,0 +5,0 @@ "leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>", |
@@ -459,2 +459,3 @@ 'use strict' | ||
* @param {number} options.maxTimeout - how long the query should maximally run, in milliseconds (default: 60000) | ||
* @param {number} options.maxNumProviders - maximum number of providers to find | ||
* @param {function(Error, Array<PeerInfo>)} callback | ||
@@ -475,8 +476,7 @@ * @returns {void} | ||
if (!options.maxTimeout) { | ||
options.maxTimeout = c.minute | ||
} | ||
options.maxTimeout = options.maxTimeout || c.minute | ||
options.maxNumProviders = options.maxNumProviders || c.K | ||
this._log('findProviders %s', key.toBaseEncodedString()) | ||
this._findNProviders(key, options.maxTimeout, c.K, callback) | ||
this._findNProviders(key, options.maxTimeout, options.maxNumProviders, callback) | ||
} | ||
@@ -483,0 +483,0 @@ |
@@ -345,2 +345,33 @@ /* eslint-env mocha */ | ||
it('find providers', function (done) { | ||
this.timeout(20 * 1000) | ||
const val = values[0] | ||
const tdht = new TestDHT() | ||
tdht.spawn(3, (err, dhts) => { | ||
expect(err).to.not.exist() | ||
series([ | ||
(cb) => connect(dhts[0], dhts[1], cb), | ||
(cb) => connect(dhts[1], dhts[2], cb), | ||
(cb) => each(dhts, (dht, cb) => dht.provide(val.cid, cb), cb), | ||
(cb) => dhts[0].findProviders(val.cid, {}, cb), | ||
(cb) => dhts[0].findProviders(val.cid, { maxNumProviders: 2 }, cb) | ||
], (err, res) => { | ||
expect(err).to.not.exist() | ||
// find providers find all the 3 providers | ||
expect(res[3]).to.exist() | ||
expect(res[3]).to.have.length(3) | ||
// find providers limited to a maxium of 2 providers | ||
expect(res[4]).to.exist() | ||
expect(res[4]).to.have.length(2) | ||
done() | ||
}) | ||
}) | ||
}) | ||
it('random-walk', function (done) { | ||
@@ -347,0 +378,0 @@ this.timeout(40 * 1000) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155720
4889