fix: on swarmInstance init, add every relay as an explicit peer

This commit is contained in:
Derrick Hammer 2023-07-24 13:24:06 -04:00
parent 5117f381f6
commit 873bc3da52
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 1 deletions

View File

@ -16,7 +16,7 @@ import { EventEmitter2 as EventEmitter } from "eventemitter2";
// @ts-ignore // @ts-ignore
import Protomux from "protomux"; import Protomux from "protomux";
import defer, { DeferredPromise } from "p-defer"; import defer, { DeferredPromise } from "p-defer";
import { concatBytes } from "@lumeweb/libkernel"; import { concatBytes, hexToBytes } from "@lumeweb/libweb";
const MAX_PEER_LISTENERS = 20; const MAX_PEER_LISTENERS = 20;
@ -134,6 +134,9 @@ async function createSwarm(): Promise<number> {
swarmInstanceEvents.emit("connection", peer); swarmInstanceEvents.emit("connection", peer);
}); });
swarmInstance.relays.forEach((relay) => {
swarmInstance.activeRelay.joinPeer(hexToBytes(relay));
});
}); });
swarmInstance.onSelf("close", (...args) => { swarmInstance.onSelf("close", (...args) => {