fix: add event listener on libp2p start for redundancy to ensure we max the events to read the peer count

This commit is contained in:
Derrick Hammer 2023-07-30 21:32:53 -04:00
parent 2b04fecc7c
commit f1b8a603df
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 0 deletions

View File

@ -339,6 +339,8 @@ async function handleStatus(aq: ActiveQuery) {
peersListener,
);
ipfs.libp2p.addEventListener("start", peersListener);
aq.setReceiveUpdate?.(() => {
peerEvents.forEach((ev) => {
// @ts-ignore
@ -347,6 +349,7 @@ async function handleStatus(aq: ActiveQuery) {
peersListener,
);
});
ipfs.libp2p.removeEventListener("start", peersListener);
aq.respond();
});