fix misbehaving check.

This commit is contained in:
Christopher Jeffrey 2016-05-26 17:36:24 -07:00
parent e59cf312c6
commit d89b545604
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -101,10 +101,12 @@ function Pool(options) {
if (options.headers == null)
options.headers = options.spv;
seeds = (options.seeds || this.network.seeds).slice();
seeds = options.seeds || this.network.seeds;
if (process.env.BCOIN_SEED)
if (process.env.BCOIN_SEED) {
seeds = seeds.slice();
seeds.unshift(process.env.BCOIN_SEED);
}
this.seeds = seeds.map(function(hostname) {
return NetworkAddress.fromHostname(hostname, self.network);
@ -1959,9 +1961,6 @@ Pool.prototype.getRandom = function getRandom(hosts, unique) {
var tries = 0;
var index, host;
if (!unique)
return hosts[Math.random() * hosts.length | 0];
for (;;) {
if (tries === hosts.length)
return;
@ -1974,7 +1973,10 @@ Pool.prototype.getRandom = function getRandom(hosts, unique) {
tries++;
}
if (this.getPeer(host.host))
if (this.isMisbehaving(host.host))
continue;
if (unique && this.getPeer(host.host))
continue;
return host;