You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When subscribing to NewBlock events (possibly also others, which I have not tested) I expect my code to receive events via the Subscription returned by the subscribe() call which is not the case.
After spending way too much time going through the code I discovered that the SubscriptionRouter stores the subscriptions internally in a HashMap<SubscriptionQuery, HashMap<SubscriptionId, SubscriptionTx>>, where SubscriptionQuery is just a type alias for a String. For the NewBlock event that then means the key ends up being "tm.event = 'NewBlock'".
Now when the client receives a message, it takes the query field inside that message to look into the hashmap. Unfortunately, I keep getting back "tm.event='NewBlock'" which is obviously not the same as "tm.event = 'NewBlock'" (missing spaces around the =).
Steps to reproduce
Take the example code from the WebSocketClient
use tendermint_rpc::{WebSocketClient,SubscriptionClient,Client};use tendermint_rpc::query::EventType;use futures::StreamExt;#[tokio::main]asyncfnmain(){let(client, driver) = WebSocketClient::new("wss://osmosis-rpc.publicnode.com:443/websocket").await.unwrap();let driver_handle = tokio::spawn(asyncmove{ driver.run().await});// Subscription functionalityletmut subs = client.subscribe(EventType::NewBlock.into()).await.unwrap();// Grab 5 NewBlock eventsletmut ev_count = 5_i32;whileletSome(res) = subs.next().await{let ev = res.unwrap();println!("Got event: {:?}", ev);
ev_count -= 1;if ev_count < 0{break;}}// Signal to the driver to terminate.
client.close().unwrap();// Await the driver's termination to ensure proper connection closure.let _ = driver_handle.await.unwrap();}
Definition of "done"
The above should print out the events.
The text was updated successfully, but these errors were encountered:
What went wrong?
When subscribing to
NewBlock
events (possibly also others, which I have not tested) I expect my code to receive events via theSubscription
returned by thesubscribe()
call which is not the case.After spending way too much time going through the code I discovered that the
SubscriptionRouter
stores the subscriptions internally in aHashMap<SubscriptionQuery, HashMap<SubscriptionId, SubscriptionTx>>
, whereSubscriptionQuery
is just a type alias for aString
. For theNewBlock
event that then means the key ends up being"tm.event = 'NewBlock'"
.Now when the client receives a message, it takes the query field inside that message to look into the hashmap. Unfortunately, I keep getting back
"tm.event='NewBlock'"
which is obviously not the same as"tm.event = 'NewBlock'"
(missing spaces around the=
).Steps to reproduce
Take the example code from the
WebSocketClient
Definition of "done"
The above should print out the events.
The text was updated successfully, but these errors were encountered: