pool: refactor dns discovery.

This commit is contained in:
Christopher Jeffrey 2016-12-19 16:58:02 -08:00
parent cc2d49ea10
commit bd4bfa142f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -396,7 +396,8 @@ Pool.prototype._connect = co(function* connect() {
this.logger.info('External IP found: %s.', ip);
}
yield this.hosts.discover();
// Try to get 16 hosts for now.
yield this.hosts.discover(16);
if (this.hosts.size() === 0)
throw new Error('No hosts available. Do you have an internet connection?');
@ -1565,10 +1566,10 @@ Pool.prototype._fillPeers = co(function* fillPeers() {
this.peers.outbound,
this.maxOutbound);
if (this.hosts.size() < need) {
if (this.hosts.size() < need && need < 10) {
this.logger.warning('Very few hosts available.');
this.logger.warning('Hitting DNS seeds again.');
yield this.hosts.discover(30);
yield this.hosts.discover();
}
for (i = 0; i < need; i++)
@ -2346,7 +2347,7 @@ HostList.prototype.discover = co(function* discover(max) {
var i, seed;
if (!max)
max = 16;
max = Infinity;
for (i = 0; i < this.seeds.length; i++) {
seed = this.seeds[i];