Waku v2: Add content filter for waku topics (#163)

* Waku v2: Add content filter for waku topics

This addresses https://github.com/vacp2p/specs/issues/156 and
https://github.com/vacp2p/specs/issues/160

* Fix spellcheck and indent

* More protobuf fmt

* spellcheck

* Update specs/waku/waku-v2.md

Co-authored-by: Dean Eigenmann <7621705+decanus@users.noreply.github.com>

Co-authored-by: Dean Eigenmann <7621705+decanus@users.noreply.github.com>
This commit is contained in:
Oskar Thorén 2020-07-28 16:11:05 +08:00 committed by GitHub
parent ffc366ac96
commit fa035fa86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 12 deletions

View File

@ -113,22 +113,28 @@ In this section we specify two things:
```protobuf ```protobuf
message RPC { message RPC {
repeated SubOpts subscriptions = 1; repeated SubOpts subscriptions = 1;
repeated Message publish = 2; repeated Message publish = 2;
repeated ContentFilter contentFilter = 3;
message SubOpts { message SubOpts {
optional bool subscribe = 1; optional bool subscribe = 1;
optional string topicid = 2; optional string topicid = 2;
} }
message ContentFilter {
optional string contentTopic = 1;
}
} }
message Message { message Message {
optional string from = 1; optional string from = 1;
optional bytes data = 2; optional bytes data = 2;
optional bytes seqno = 3; optional bytes seqno = 3;
repeated string topicIDs = 4; repeated string topicIDs = 4;
optional bytes signature = 5; optional bytes signature = 5;
optional bytes key = 6; optional bytes key = 6;
optional string contentTopic = 7;
} }
``` ```
@ -137,6 +143,11 @@ However, later versions will add likely add this capability.
`TopicDescriptor` as defined in the PubSub interface spec is not currently used. `TopicDescriptor` as defined in the PubSub interface spec is not currently used.
### RPC
These are messages sent to directly connected peers. They SHOULD NOT be
gossiped. See section below on how the fields work.
### Message ### Message
The `from` field MAY indicate which peer is publishing the message. The `from` field MAY indicate which peer is publishing the message.
@ -164,6 +175,22 @@ The `topicid` field MUST contain the topic.
NOTE: This doesn't appear to be documented in PubSub spec, upstream? NOTE: This doesn't appear to be documented in PubSub spec, upstream?
### ContentFilter
Content filter is a way to do [message-based
filtering](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern#Message_filtering).
Currently the only content filter being applied is on `contentTopic`. This
corresponds to topics in Waku v1.
A node that only sets this field but doesn't subscribe to any topic SHOULD only
get notified when the content subtopic matches. A content subtopic matches when
a message `contentTopic` is the same. This means such a node acts as a light node.
A node that receives this RPC SHOULD apply this content filter before relaying.
Since such a node is doing extra work for a light node, it MAY also account for
usage and be selective in how much service it provides. This mechanism is
currently planned but underspecified.
### Historical message support ### Historical message support
TODO(Dean): Fill out this section with historical message API. TODO(Dean): Fill out this section with historical message API.
@ -200,3 +227,5 @@ Copyright and related rights waived via
6. [Whisper spec (EIP627)](https://eips.ethereum.org/EIPS/eip-627) 6. [Whisper spec (EIP627)](https://eips.ethereum.org/EIPS/eip-627)
7. [Waku v2 plan](https://vac.dev/waku-v2-plan) 7. [Waku v2 plan](https://vac.dev/waku-v2-plan)
8. [Message Filtering (Wikipedia)](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern#Message_filtering)

View File

@ -22,6 +22,9 @@ cas
changelog changelog
Changelog Changelog
COSS COSS
ContentFilter
contentFilter
contentTopic
CPU CPU
DAG DAG
DAGs DAGs
@ -127,6 +130,7 @@ subprotocols
TBD TBD
TCP TCP
textlint textlint
topicid
topicIDs topicIDs
Thorén Thorén
tla tla