*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) => {
|
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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue