add back old peer seed code.

This commit is contained in:
Christopher Jeffrey 2016-01-22 18:35:13 -08:00
parent ef09a776fe
commit 9a60ae8e50

View File

@ -1581,10 +1581,35 @@ 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
// an address.
if (!priority) {
if (connecting)
if (all.length === 1)
return all[Math.random() * (all.length - 1) | 0];
}