pool: refactor dns discovery.

This commit is contained in:
Christopher Jeffrey 2016-12-19 07:32:42 -08:00
parent aa07255d74
commit b38d859382
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1568,7 +1568,7 @@ Pool.prototype._fillPeers = co(function* fillPeers() {
if (this.hosts.size() < need) {
this.logger.warning('Very few hosts available.');
this.logger.warning('Hitting DNS seeds again.');
yield this.hosts.discover(this.maxOutbound * 4);
yield this.hosts.discover(30);
}
for (i = 0; i < need; i++)
@ -2338,21 +2338,22 @@ HostList.prototype.addSeed = function addSeed(hostname) {
/**
* Discover hosts from seeds.
* @param {Number?} max
* @returns {Promise}
*/
HostList.prototype.discover = co(function* discover(total) {
HostList.prototype.discover = co(function* discover(max) {
var i, seed;
if (!total)
total = 16;
if (!max)
max = 16;
for (i = 0; i < this.seeds.length; i++) {
seed = this.seeds[i];
yield this.populate(seed);
if (this.list.size >= total)
if (this.list.size >= max)
break;
}
});