add info on contentTopics parameter

This commit is contained in:
LordGhostX 2024-06-16 16:22:26 +01:00
parent 5af75255af
commit c909c3f621
No known key found for this signature in database
GPG Key ID: 520CC5DC4F94FCC7

View File

@ -24,13 +24,17 @@ await node.start();
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.
:::
A node needs to know how to route messages. In order to do that you can use standard pubsub topic (`/waku/2/default-waku/proto`). If your project uses a different shared pubsub topic, you can configure this using the `ShardInfo` parameter or by using a set of `contentTopics` that your node will be using:
A node needs to know how to route messages. In order to do that you can use standard pubsub topic (`/waku/2/default-waku/proto`). If your project uses a different pubsub topic, you can configure this by providing a set of [content topics](/learn/concepts/content-topics) for the node to use with the `contentTopics` parameter or by using the `ShardInfo` parameter:
```js
// Create the shard info
const shardInfo = { clusterId: 3, shards: [1, 2] };
// Create node with content topics
const node = await createLightNode({
defaultBootstrap: true,
contentTopics: [/*set of content topics*/],
});
// Create node with custom shard info
const shardInfo = { clusterId: 3, shards: [1, 2] };
const node = await createLightNode({
defaultBootstrap: true,
shardInfo: shardInfo,
@ -59,7 +63,7 @@ await waitForRemotePeer(node, [Protocols.LightPush, Protocols.Filter]);
## Choose a content topic
[Choose a content topic](/learn/concepts/content-topics) for your application and create a message `encoder` and `decoder`:
Choose a [content topic](/learn/concepts/content-topics) for your application and create a message `encoder` and `decoder`:
```js
import { createEncoder, createDecoder } from "@waku/sdk";