*Fix usage of connection

This commit is contained in:
Derrick Hammer 2022-07-26 22:56:49 -04:00
parent b4962e994b
commit 007b9a09d7
1 changed files with 4 additions and 7 deletions

View File

@ -123,8 +123,8 @@ export default class DHT {
}
private async fillConnections(): Promise<any> {
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);