Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce new waitForPeers API #226

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/guides/js-waku/configure-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 4 additions & 6 deletions docs/guides/js-waku/light-send-receive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/js-waku/store-retrieve-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading