*Abort if no available relays to process

This commit is contained in:
Derrick Hammer 2022-07-26 21:36:30 -04:00
parent a0ecea1dc9
commit 35eed2a157
1 changed files with 3 additions and 0 deletions

View File

@ -118,6 +118,9 @@ export default class DHT {
private async fillConnections(): Promise<any> {
let available = [...this._relays.keys()].filter(x => [...this._activeRelays.keys()].includes(x));
let relayPromises = [];
if (0 > available.length) {
return;
}
while (this._activeRelays.size <= Math.min(this._maxConnections, available.length + this._activeRelays.size)) {
const relayIndex = await randomNumber(0, available.length - 1);