fix misbehaving check.
This commit is contained in:
parent
e59cf312c6
commit
d89b545604
@ -101,10 +101,12 @@ function Pool(options) {
|
|||||||
if (options.headers == null)
|
if (options.headers == null)
|
||||||
options.headers = options.spv;
|
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);
|
seeds.unshift(process.env.BCOIN_SEED);
|
||||||
|
}
|
||||||
|
|
||||||
this.seeds = seeds.map(function(hostname) {
|
this.seeds = seeds.map(function(hostname) {
|
||||||
return NetworkAddress.fromHostname(hostname, self.network);
|
return NetworkAddress.fromHostname(hostname, self.network);
|
||||||
@ -1959,9 +1961,6 @@ Pool.prototype.getRandom = function getRandom(hosts, unique) {
|
|||||||
var tries = 0;
|
var tries = 0;
|
||||||
var index, host;
|
var index, host;
|
||||||
|
|
||||||
if (!unique)
|
|
||||||
return hosts[Math.random() * hosts.length | 0];
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (tries === hosts.length)
|
if (tries === hosts.length)
|
||||||
return;
|
return;
|
||||||
@ -1974,7 +1973,10 @@ Pool.prototype.getRandom = function getRandom(hosts, unique) {
|
|||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getPeer(host.host))
|
if (this.isMisbehaving(host.host))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (unique && this.getPeer(host.host))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return host;
|
return host;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user