How to use an OR condition with the Tendermint websocket /subscribe method?

729 Views Asked by At

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!

3

There are 3 best solutions below

0
zmanian On

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

0
Thane Thomson On

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

0
okwme On

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.