From 35eed2a157230595a0051f01b328deebdad1145d Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 26 Jul 2022 21:36:30 -0400 Subject: [PATCH] *Abort if no available relays to process --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 0351918..eb5caae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -118,6 +118,9 @@ export default class DHT { private async fillConnections(): Promise { 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);