From 2d30390fa26efc3addc8d515510a1229bbca9908 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 18 Mar 2023 15:07:52 -0400 Subject: [PATCH] *fix listener callback --- src/modules/rpc.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/rpc.ts b/src/modules/rpc.ts index 2464b19..852da9d 100644 --- a/src/modules/rpc.ts +++ b/src/modules/rpc.ts @@ -30,15 +30,16 @@ export async function getRpcByPeer(peer: Buffer | string) { } return new Promise((resolve) => { - const listener = () => {}; - swarm.on("connection", (peer: any, info: any) => { + const listener = (peer: any, info: any) => { if (info.publicKey.toString("hex") !== peer.toString("hex")) { return; } swarm.removeListener("connection", listener); resolve(setupStream(peer)); - }); + }; + + swarm.on("connection", listener); swarm.joinPeer(peer); });