*Store copy of activeRelay size to prevent infinite loop

This commit is contained in:
Derrick Hammer 2022-07-26 23:09:25 -04:00
parent 8ee4df8d1b
commit 7cb32b716a
1 changed files with 4 additions and 1 deletions

View File

@ -130,9 +130,12 @@ export default class DHT {
if (0 === available.length) {
return;
}
const activeRelays = this._activeRelays.size;
while (
this._activeRelays.size <=
Math.min(this._maxConnections, available.length + this._activeRelays.size)
Math.min(this._maxConnections, available.length + activeRelays)
) {
const relayIndex = await randomNumber(0, available.length - 1);