chore: update doc for setting static peers (#179)

This commit is contained in:
Sasha 2024-03-08 05:06:21 +01:00 committed by GitHub
parent c01ee1ee10
commit cfa2c623e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 42 deletions

View File

@ -26,43 +26,14 @@ const node = await createLightNode({ defaultBootstrap: true });
## Configure static peers ## Configure static peers
To bootstrap a node using [static peers](/learn/concepts/static-peers), first install the `@libp2p/bootstrap` package: To set [static peers](/learn/concepts/static-peers), a list of `multiaddr` to bootstrap the node should be passed to the `bootstrapPeers` parameter of the `createLightNode()` function:
```mdx-code-block
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
```
<Tabs groupId="package-manager">
<TabItem value="npm" label="NPM">
```shell
npm install @libp2p/bootstrap
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```shell
yarn add @libp2p/bootstrap
```
</TabItem>
</Tabs>
Then, use the `bootstrap()` function to provide a list of `multiaddr` to bootstrap the node:
```js ```js
import { createLightNode } from "@waku/sdk"; import { createLightNode } from "@waku/sdk";
import { bootstrap } from "@libp2p/bootstrap";
// Bootstrap node using static peers // Bootstrap node using static peers
const node = await createLightNode({ const node = await createLightNode({
libp2p: { bootstrapPeers: ["[PEER MULTIADDR]"],
peerDiscovery: [
bootstrap({ list: ["[PEER MULTIADDR]"] }),
],
},
}); });
``` ```
@ -77,11 +48,7 @@ const peers = [
// Bootstrap node using the static peers // Bootstrap node using the static peers
const node = await createLightNode({ const node = await createLightNode({
libp2p: { bootstrapPeers: peers,
peerDiscovery: [
bootstrap({ list: peers }),
],
},
}); });
``` ```
@ -179,11 +146,11 @@ const NODE_REQUIREMENTS = {
filter: 3, filter: 3,
}; };
// Bootstrap node using DNS Discovery // Bootstrap node using DNS Discovery and static peers
const node = await createLightNode({ const node = await createLightNode({
libp2p: { libp2p: {
bootstrapPeers: peers,
peerDiscovery: [ peerDiscovery: [
bootstrap({ list: peers }),
wakuDnsDiscovery( wakuDnsDiscovery(
[enrTree["PROD"]], [enrTree["PROD"]],
NODE_REQUIREMENTS, NODE_REQUIREMENTS,

View File

@ -21,7 +21,7 @@ await node.start();
``` ```
:::info :::info
When the `defaultBootstrap` option is set to `true`, your node will be bootstrapped using the [default bootstrap method](/guides/js-waku/configure-discovery#default-bootstrap-method). Have a look at the [Bootstrap Nodes and Discover Peers](/guides/js-waku/configure-discovery) guide to learn more methods to bootstrap nodes. When the `defaultBootstrap` parameter is set to `true`, your node will be bootstrapped using the [default bootstrap method](/guides/js-waku/configure-discovery#default-bootstrap-method). Have a look at the [Bootstrap Nodes and Discover Peers](/guides/js-waku/configure-discovery) guide to learn more methods to bootstrap nodes.
::: :::
## Connect to remote peers ## Connect to remote peers
@ -35,7 +35,7 @@ import { waitForRemotePeer } from "@waku/sdk";
await waitForRemotePeer(node); await waitForRemotePeer(node);
``` ```
The `protocols` option allows you to specify the [protocols](/learn/concepts/protocols) that the remote peers should have enabled: The `protocols` parameter allows you to specify the [protocols](/learn/concepts/protocols) that the remote peers should have enabled:
```js ```js
import { waitForRemotePeer, Protocols } from "@waku/sdk"; import { waitForRemotePeer, Protocols } from "@waku/sdk";
@ -62,7 +62,7 @@ const encoder = createEncoder({ contentTopic });
const decoder = createDecoder(contentTopic); const decoder = createDecoder(contentTopic);
``` ```
The `ephemeral` option allows you to specify whether messages should **NOT** be stored by [Store peers](/guides/js-waku/store-retrieve-messages): The `ephemeral` parameter allows you to specify whether messages should **NOT** be stored by [Store peers](/guides/js-waku/store-retrieve-messages):
```js ```js
const encoder = createEncoder({ const encoder = createEncoder({

View File

@ -136,7 +136,7 @@ Message signing helps in proving the authenticity of received messages. By attac
Signing messages is only possible when encrypted, but if your application does not require encryption, you can generate a symmetric key through hardcoded or deterministic methods using information available to all users. Signing messages is only possible when encrypted, but if your application does not require encryption, you can generate a symmetric key through hardcoded or deterministic methods using information available to all users.
::: :::
The `sigPrivKey` option allows the `Symmetric` and `ECIES` message `encoders` to sign the message before encryption using an `ECDSA` private key: The `sigPrivKey` parameter allows the `Symmetric` and `ECIES` message `encoders` to sign the message before encryption using an `ECDSA` private key:
```js title="Alice (sender) client" ```js title="Alice (sender) client"
import { generatePrivateKey, getPublicKey } from "@waku/message-encryption"; import { generatePrivateKey, getPublicKey } from "@waku/message-encryption";