fix misbehaving check.
This commit is contained in:
parent
e59cf312c6
commit
d89b545604
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user