From 2ed88e1818ddc183324614919c849e9e53498370 Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 10 Oct 2024 23:42:13 +0200 Subject: [PATCH] feat: introduce new waitForPeers API --- docs/guides/js-waku/configure-discovery.md | 4 ++-- docs/guides/js-waku/light-send-receive.md | 10 ++++------ docs/guides/js-waku/store-retrieve-messages.md | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/guides/js-waku/configure-discovery.md b/docs/guides/js-waku/configure-discovery.md index 841a5020..66af8099 100644 --- a/docs/guides/js-waku/configure-discovery.md +++ b/docs/guides/js-waku/configure-discovery.md @@ -191,10 +191,10 @@ const node = await createLightNode({ You can retrieve the array of peers connected to a node using the `libp2p.getPeers()` function within the `@waku/sdk` package: ```js -import { createLightNode, waitForRemotePeer } from "@waku/sdk"; +import { createLightNode } from "@waku/sdk"; const node = await createLightNode({ defaultBootstrap: true }); -await waitForRemotePeer(node); +await node.waitForPeers(); // Retrieve array of peers connected to the node console.log(node.libp2p.getPeers()); diff --git a/docs/guides/js-waku/light-send-receive.md b/docs/guides/js-waku/light-send-receive.md index 809a767d..fd626040 100644 --- a/docs/guides/js-waku/light-send-receive.md +++ b/docs/guides/js-waku/light-send-receive.md @@ -54,22 +54,20 @@ const node = await createLightNode({ ## Connect to remote peers -Use the `waitForRemotePeer()` function to wait for the node to connect with peers on the Waku Network: +Use the `node.waitForPeers()` function to wait for the node to connect with peers on the Waku Network: ```js -import { waitForRemotePeer } from "@waku/sdk"; - // Wait for a successful peer connection -await waitForRemotePeer(node); +await node.waitForPeers(); ``` The `protocols` parameter allows you to specify the [protocols](/learn/concepts/protocols) that the remote peers should have enabled: ```js -import { waitForRemotePeer, Protocols } from "@waku/sdk"; +import { Protocols } from "@waku/sdk"; // Wait for peer connections with specific protocols -await waitForRemotePeer(node, [Protocols.LightPush, Protocols.Filter]); +await node.waitForPeers([Protocols.LightPush, Protocols.Filter]); ``` ## Choose a content topic diff --git a/docs/guides/js-waku/store-retrieve-messages.md b/docs/guides/js-waku/store-retrieve-messages.md index 293a7f12..c09d8c97 100644 --- a/docs/guides/js-waku/store-retrieve-messages.md +++ b/docs/guides/js-waku/store-retrieve-messages.md @@ -19,13 +19,13 @@ await node.start(); ## Connect to store peers -Use the `waitForRemotePeer()` function to wait for the node to connect with Store peers: +Use the `node.waitForPeers()` method to wait for the node to connect with Store peers: ```js -import { waitForRemotePeer, Protocols } from "@waku/sdk"; +import { Protocols } from "@waku/sdk"; // Wait for a successful peer connection -await waitForRemotePeer(node, [Protocols.Store]); +await node.waitForPeers([Protocols.Store]); ``` ## Choose a content topic