mirror of
https://github.com/acid-info/waku.guide.git
synced 2025-02-24 15:58:34 +00:00
47 lines
2.2 KiB
Markdown
47 lines
2.2 KiB
Markdown
|
---
|
|||
|
title: Content Topic and How to Choose One
|
|||
|
---
|
|||
|
|
|||
|
A content topic is used for content based filtering and allows you to filter out the messages that your dApp processes,
|
|||
|
both when receiving live messages (Relay or Filter) or retrieving historical messages (Store).
|
|||
|
|
|||
|
The recommended format for content topics is as follows:
|
|||
|
|
|||
|
`/{dapp-name}/{version}/{content-topic-name}/{encoding}`
|
|||
|
|
|||
|
- `dapp-name`: The name of your dApp, it must be unique to avoid conflict with other dApps.
|
|||
|
- `version`: We usually start at `1`, useful when introducing breaking changes in your messages.
|
|||
|
- `content-topic-name`: The actual content topic name to use for filtering.
|
|||
|
If your dApp uses Waku for several features,
|
|||
|
you should use a content topic per feature.
|
|||
|
- `encoding`: The encoding format of the message, [Protobuf](https://developers.google.com/protocol-buffers) is most often used: `proto`.
|
|||
|
|
|||
|
For example: Your dApp's name is SuperCrypto,
|
|||
|
it enables users to receive notifications and send private messages.
|
|||
|
You may want to use the following content topics:
|
|||
|
|
|||
|
- `/supercrypto/1/notification/proto`
|
|||
|
- `/supercrypto/1/private-message/proto`
|
|||
|
|
|||
|
## PubSub topic
|
|||
|
|
|||
|
There is another type of a _topic_ in Waku: A pubsub topic is used for routing of messages between the relaying nodes in the Waku network.
|
|||
|
|
|||
|
> This section talks more about how networking and relaying of messages is handled by the nodes in the network,
|
|||
|
> and has little to do with the application layer of Waku.
|
|||
|
> Feel free to skip ahead this section if you are not interested in the details of how Waku works.
|
|||
|
|
|||
|
The format for a pubsub topic is as follows:
|
|||
|
`/waku/2/{topic-name}/{encoding}` and the default pubsub topic is `/waku/2/default-waku/proto`.
|
|||
|
|
|||
|
This indicates to:
|
|||
|
|
|||
|
1. `waku`: Waku problem domain
|
|||
|
2. `2`: Version is 2
|
|||
|
3. `default-waku`: Default topic for exchanging WakuMessages
|
|||
|
4. `proto`: The data field in PubSub is serialized/encoded as Protobuf as determined by WakuMessage
|
|||
|
|
|||
|
Unless there’s a good reason, the default PubSub topic is used for all protocols. However, in certain situations other topics may be used.
|
|||
|
|
|||
|
Using a single PubSub topic ensures a connected network, as well some degree of metadata protection. See [Anonymity/Unlinkability](https://rfc.vac.dev/spec/10/#anonymity--unlinkability) for more details.
|