*fix listener callback
This commit is contained in:
parent
d3d0f387b6
commit
2d30390fa2
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue