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