2

What's the best way to implement an OR condition in the query of a Tendermint websocket /subscribe method? https://docs.tendermint.com/master/rpc/#/Websocket/subscribe

Specifically I want to query message.sender='${address}' OR transfer.recipient='${address}'. The solution I have right now is to do 2 /subscribe requests with the same jsonrpc id, but that's ugly, wasteful, and I have to filter out events that are triggered twice.

If I had AND and NOT then a OR b = NOT((NOT a) AND (NOT b)), but it doesn't seem like NOT is implemented: https://godoc.org/github.com/tendermint/tendermint/libs/pubsub/query#Operator

Thanks!

assafmo
  • 1,047
  • 3
  • 15
  • 32
  • 1
    I'm told by the tm-core team that his seems like a feature that an outside contributor would be able to make relatively easy. They said it also seems like the type of issue that wouldn't need a lot of overhead reviewing the work (which means it could be merged quickly). Would you mind making an issue on the [tm repo][1]? Maybe you could consider whether your team has the resources to implement it as outside contributors in order to see if happen quickly? Otherwise it could get triaged as a feature request in the Tendermint roadmap. [1]: https://github.com/tendermint/tendermint – okwme Jan 14 '21 at 12:18

3 Answers3

3

Last time I tried this on Tendermint 0.33, Boolean conditions did not work in /subscribe

zmanian
  • 426
  • 4
  • 8
3

Logical OR to join conditions isn't supported at present.

The query language is very simple right now. The only logical operator implemented to join separate conditions at present is AND, as per the PEG.

For example: tm.event = 'Tx' AND tx.hash = 'XYZ' AND tx.height = 5

Thane Thomson
  • 403
  • 1
  • 4
  • 14
3

Bez from Tendermint Core has agreed to take this on! Here's the issue if you'd like to follow or contribute. He says he'll be able to focus on it after the p2p reactor refactor.

okwme
  • 740
  • 1
  • 7
  • 19