mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-09 01:03:11 +00:00
* feat: lightpush & filter send requests to multiple peers * build message-hash before core * chore: restructure folder heirrarchy * fix: imports * chore: move @waku/core to dev deps * feat: create a new `ServiceNodes` wrapper class to encapsulate service node and message collector with redundancy accounted for * chore(filter): move tests against single service node to a subdir * feat: support relay, add strict checking, add tests * fix(filter): handle errors * chore(tests): add tests for ping * add tests for push * chore: abstract redundancy * feat: add unsubscribe tests * fix: tests * add lightpush tests * fix: imports * fix: merge & add warning * merge: master * fix: breaking tests with master * address comments * make num peers configurable * fix: typo
21 lines
555 B
TypeScript
21 lines
555 B
TypeScript
import type { LightNode } from "@waku/interfaces";
|
|
export async function waitForConnections(
|
|
numPeers: number,
|
|
waku: LightNode
|
|
): Promise<void> {
|
|
let connectionsLen = waku.libp2p.getConnections().length;
|
|
if (connectionsLen >= numPeers) {
|
|
return;
|
|
}
|
|
await new Promise<void>((resolve) => {
|
|
const cb = (): void => {
|
|
connectionsLen++;
|
|
if (connectionsLen >= numPeers) {
|
|
waku.libp2p.removeEventListener("peer:identify", cb);
|
|
resolve();
|
|
}
|
|
};
|
|
waku.libp2p.addEventListener("peer:identify", cb);
|
|
});
|
|
}
|