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
use electrum_client::{Client,ElectrumApi};fnmain(){let client = electrum_client::raw_client::RawClient::new(("blockstream.info",143),None).unwrap();let r = client.block_headers_subscribe().unwrap();// print, but just oncedbg!(r);loop{
std::thread::sleep(std::time::Duration::from_secs(5));let x = client.block_headers_pop().unwrap();// always is Nonedbg!(x);}}
client.block_headers_pop() is always None.
All clinet's jsonrpc calls use the self.call method. The self.call method constructs a request containing the id, and uses self.recv to wait for the result of the corresponding id. In self.recv, use self._reader_thread to wait for the result of this id, and then exit, ignoring the subsequent results of the subscription method.
Since this is a synchronous library, I looked for some trace of std::thead::spawn in the code, but couldn't find it.
Is my calling method wrong? This is a library that has been around for a long time. I think this is the reason. If yes, is it possible to add example code? This problem is really a headache.
When calling the subscription method, can a channel be returned instead of putting all the results into a VecDeque, which still requires the user to constantly check whether there is new data?
The text was updated successfully, but these errors were encountered:
client.block_headers_pop()
is always None.All clinet's jsonrpc calls use the
self.call
method. Theself.call
method constructs a request containing the id, and usesself.recv
to wait for the result of the corresponding id. Inself.recv
, useself._reader_thread
to wait for the result of this id, and then exit, ignoring the subsequent results of the subscription method.Since this is a synchronous library, I looked for some trace of std::thead::spawn in the code, but couldn't find it.
The text was updated successfully, but these errors were encountered: