-
Notifications
You must be signed in to change notification settings - Fork 60
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
feature/filter #63
Merged
Merged
feature/filter #63
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e0f2ab8
simplified filter
decanus 9078a9a
add filter
decanus 05c7df5
eol
decanus f199b83
Merge branch 'master' into feature/filter
decanus 66bb2bc
Merge branch 'master' into feature/filter
decanus a03311a
Update waku_protocol2.nim
decanus 2610e50
Merge branch 'master' into feature/filter
decanus 330e40b
trigger GitHub actions
decanus 9f9ba08
comment
decanus 5dfaad2
Merge branch 'master' into feature/filter
decanus 355201c
fix import
decanus 3ad5294
merge
decanus eb8892e
oops
decanus 3a72b62
and
decanus 114d944
init filters
decanus 0065cab
import tables
decanus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import | ||
tables | ||
|
||
type | ||
|
||
FilterMessageHandler* = proc(msg: seq[byte]) {.gcsafe, closure.} | ||
|
||
Filter* = object | ||
topics: seq[string] # @TODO TOPIC | ||
handler: FilterMessageHandler | ||
|
||
Filters* = Table[string, Filter] | ||
|
||
proc init*(T: type Filter, topics: seq[string], handler: FilterMessageHandler): T = | ||
result = T( | ||
topics: topics, | ||
handler: handler | ||
) | ||
|
||
proc notify*(filters: var Filters, topic: string, msg: seq[byte]) {.gcsafe.} = | ||
for filter in filters.mvalues: | ||
if filter.topics.len > 0 and topic notin filter.topics: | ||
continue | ||
|
||
filter.handler(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are mixing the GossipSub/FloodSub topic(s) here with the ones of Waku. The current idea/plan is that these are not the same.
So the way I see to do this is as follows: a Waku
subscribe
should subscribe a WakuSub handler on the "general" chosen topic (=GossipSub/FloodSub topic) for WakuSub communication, and use that WakuSub handler, to filter messages according the providedWaku
topics, and then trigger the Waku handler.I realize this probably sounds very confusing :), the naming isn't great.
And that would be in the case of full nodes. Light nodes would require another system probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so then I have another problem. I need to decode the message. But from my understanding we do not yet have a message format do we? Hence my asking in nim-waku. Maybe @oskarth could also elaborate here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what this PR is even trying to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a message format. It is documented here: https://specs.vac.dev/specs/waku/waku-v2.html#message
What isn't fully specced out there is: (a) how to deal with waku/content topics (not pubsub topics) and (b) how to deal with encryption of payload. Neither is necessary at this stage for the issues discussed on e.g. Monday.
For (a) there is vacp2p/rfc#156 and vacp2p/rfc#160 For (b) there is vacp2p/rfc#158
You don't need either to get a generic Topic Handler going.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you make a good point that this extra filter that doesn't do anything currently (as it uses the same topic) is not needed to make this work. I thought it was fine as in my envision of the API, the filter would eventually filter messages on Waku topics which are provided through the subscribe call.