cleanup old tries code.
This commit is contained in:
parent
9476f7f70a
commit
ef09a776fe
@ -1581,35 +1581,10 @@ Pool.prototype.usableSeed = function usableSeed(priority, connecting) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try the rest of the peers second.
|
|
||||||
for (i = 0; i < seeds.length; i++) {
|
|
||||||
addr = seeds[i];
|
|
||||||
assert(addr.host);
|
|
||||||
if (this.getPeer(addr))
|
|
||||||
continue;
|
|
||||||
if (this.isMisbehaving(addr.host))
|
|
||||||
continue;
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are a priority socket, try to find a
|
|
||||||
// peer this time with looser requirements.
|
|
||||||
if (priority) {
|
|
||||||
for (i = 0; i < seeds.length; i++) {
|
|
||||||
addr = seeds[i];
|
|
||||||
assert(addr.host);
|
|
||||||
if (this.peers.load && this.getPeer(addr) === this.peers.load)
|
|
||||||
continue;
|
|
||||||
if (this.isMisbehaving(addr.host))
|
|
||||||
continue;
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have no block peers, always return
|
// If we have no block peers, always return
|
||||||
// an address.
|
// an address.
|
||||||
if (!priority) {
|
if (!priority) {
|
||||||
if (all.length === 1)
|
if (connecting)
|
||||||
return all[Math.random() * (all.length - 1) | 0];
|
return all[Math.random() * (all.length - 1) | 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user