Skip to content
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

shh_newFilter: update API to allow complex topics #175

Closed
karalabe opened this issue Apr 21, 2015 · 3 comments
Closed

shh_newFilter: update API to allow complex topics #175

karalabe opened this issue Apr 21, 2015 · 3 comments
Labels
Bug Addressing a bug Enhancement Includes improvements or optimizations

Comments

@karalabe
Copy link
Contributor

The idea is to allow specifying potentially nested topic lists to create complex filter criteria. At the highest level the topics argument is still a list, but each element may be one of:

  • string: as used previously
  • null: signalling a wildcard/match-all
  • string array: to match any element within

A few samples:

shh.filter({}).watch(function(err, msg) {
    console.log("Empty catcher:", msg)
})
shh.filter({topics: ["singleton"]}).watch(function(err, msg) {
    console.log("Single catcher:", msg)
})
shh.filter({topics: ["a", "b"]}).watch(function(err, msg) {
    console.log("Multi catcher:", msg)
})
shh.filter({topics: [["1", "2"]]}).watch(function(err, msg) {
    console.log("Binary catcher:", msg)
})
shh.filter({topics: [null, "x"]}).watch(function(err, msg) {
    console.log("Wildcard catcher:", msg)
})

These currently produce these JSON requests, the last two of which seem wrong

[{"topics":[]}]
[{"topics":["0x73696e676c65746f6e"]}]
[{"topics":["0x61","0x62"]}]
[{"topics":["0x5b2231222c2232225d"]}]
[{"topics":["0x6e756c6c","0x78"]}]
@frozeman
Copy link
Contributor

Thats currently not supported. @debris we would need to modifiy the topics parser to parse even two dimensions and transform values to hex (if not already)

Though it would affect eth filters as well, so we have to make sure that when using eth its flattened afterwards.

@frozeman frozeman added the Enhancement Includes improvements or optimizations label Apr 21, 2015
@frozeman
Copy link
Contributor

@debris Thats how topics filtering in whisper is now implemented in go:

[A, B] = A && B
[A, [B, C]] = A && (B || C)
[NULL, A, B] = ANYTHING && A && B

null is wildcard

we should make sure its the same in cpp and add this to the docs.

debris added a commit that referenced this issue Apr 21, 2015
frozeman added a commit that referenced this issue Apr 21, 2015
@frozeman
Copy link
Contributor

fixed in c8f4226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug Enhancement Includes improvements or optimizations
Projects
None yet
Development

No branches or pull requests

2 participants