From 007b9a09d722b6a02e18cf5f244ceb964d0bc5c8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 26 Jul 2022 22:56:49 -0400 Subject: [PATCH] *Fix usage of connection --- src/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 56772a6..b3ad884 100644 --- a/src/index.ts +++ b/src/index.ts @@ -123,8 +123,8 @@ export default class DHT { } private async fillConnections(): Promise { - let available = [...this._relays.keys()].filter((x) => - ![...this._activeRelays.keys()].includes(x) + let available = [...this._relays.keys()].filter( + (x) => ![...this._activeRelays.keys()].includes(x) ); let relayPromises = []; if (0 === available.length) { @@ -136,17 +136,14 @@ export default class DHT { ) { const relayIndex = await randomNumber(0, available.length - 1); - const connection = available[relayIndex]; + const connection = this._relays.get(available[relayIndex]); if (!this.isServerAvailable(connection)) { continue; } const node = new DhtNode( - new Stream( - true, - new WebSocket(this._relays.get(connection) as string) - ), + new Stream(true, new WebSocket(connection)), this._options ); this._activeRelays.set(available[relayIndex], node);