*fix listener callback

This commit is contained in:
Derrick Hammer 2023-03-18 15:07:52 -04:00
parent d3d0f387b6
commit 2d30390fa2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 3 deletions

View File

@ -30,15 +30,16 @@ export async function getRpcByPeer(peer: Buffer | string) {
} }
return new Promise((resolve) => { return new Promise((resolve) => {
const listener = () => {}; const listener = (peer: any, info: any) => {
swarm.on("connection", (peer: any, info: any) => {
if (info.publicKey.toString("hex") !== peer.toString("hex")) { if (info.publicKey.toString("hex") !== peer.toString("hex")) {
return; return;
} }
swarm.removeListener("connection", listener); swarm.removeListener("connection", listener);
resolve(setupStream(peer)); resolve(setupStream(peer));
}); };
swarm.on("connection", listener);
swarm.joinPeer(peer); swarm.joinPeer(peer);
}); });