Skip to content

wollet: workaround subscriptions not persisting with reconnects #47

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

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lwk_wollet/src/clients/electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,21 @@ impl super::BlockchainBackend for ElectrumClient {
popped_header = Some(header)
}

if let Some(popped_header) = popped_header {
let tip: BlockHeader = elements_deserialize(&popped_header.header)?;
self.tip = tip;
match popped_header {
Some(header) => {
let tip: BlockHeader = elements_deserialize(&header.header)?;
self.tip = tip;
}
None => {
// https://github.com/bitcoindevkit/rust-electrum-client/issues/124
// It might be that the client has reconnected and subscriptions don't persist
// across connections. Calling `client.ping()` won't help here because the
// successful retry will prevent us knowing about the reconnect.
if let Ok(header) = self.client.block_headers_subscribe_raw() {
let tip: BlockHeader = elements_deserialize(&header.header)?;
self.tip = tip;
}
}
}

Ok(self.tip.clone())
Expand Down
Loading