waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
171 stars 42 forks source link

feat: replace `waitForRemotePeers()` with `waku.waitForPeer()` method #2161

Closed weboko closed 1 month ago

weboko commented 1 month ago

Problem

We have a common pattern when users absolutely need to:

import { createLigthNode, waitForRemotePeers } from "@waku/sdk";

const waku = createLigthNode();

await waku.start();
await waitForRemotePeers(waku);

This PR makes IWaku self sufficient:

import { createLigthNode } from "@waku/sdk";

const waku = createLigthNode();

await waku.start();
await waku.waitForPeer();

Other stuff

Notes

github-actions[bot] commented 1 month ago

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 84.23 KB (+0.73% 🔺) 1.7 s (+0.73% 🔺) 4 s (-1.66% 🔽) 5.7 s
Waku Simple Light Node 135 KB (-0.34% 🔽) 2.8 s (-0.34% 🔽) 5.1 s (+53.43% 🔺) 7.8 s
ECIES encryption 22.94 KB (0%) 459 ms (0%) 1.3 s (+51.41% 🔺) 1.8 s
Symmetric encryption 22.39 KB (0%) 448 ms (0%) 1.3 s (+13.09% 🔺) 1.7 s
DNS discovery 72.28 KB (0%) 1.5 s (0%) 2.8 s (-29.18% 🔽) 4.2 s
Peer Exchange discovery 73.88 KB (0%) 1.5 s (0%) 3.6 s (+31.76% 🔺) 5.1 s
Local Peer Cache Discovery 67.63 KB (0%) 1.4 s (0%) 3.3 s (+21.97% 🔺) 4.7 s
Privacy preserving protocols 75.61 KB (+1.06% 🔺) 1.6 s (+1.06% 🔺) 3.3 s (-28.36% 🔽) 4.8 s
Waku Filter 78.58 KB (-0.12% 🔽) 1.6 s (-0.12% 🔽) 4.2 s (+16.59% 🔺) 5.8 s
Waku LightPush 76.83 KB (-0.08% 🔽) 1.6 s (-0.08% 🔽) 3.8 s (+17.9% 🔺) 5.4 s
History retrieval protocols 76.09 KB (+0.17% 🔺) 1.6 s (+0.17% 🔺) 2.8 s (-27.62% 🔽) 4.3 s
Deterministic Message Hashing 7.38 KB (0%) 148 ms (0%) 501 ms (-30.84% 🔽) 649 ms