Skip to content

Commit

Permalink
Drop wallet lock before sleeping and retrying
Browse files Browse the repository at this point in the history
.. no need to keep the wallet locked if we're sleeping. So we're
dropping and re-locking.
  • Loading branch information
tnull committed Mar 18, 2024
1 parent 32bf929 commit d070050
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ where
Err(e) => match e {
bdk::Error::Esplora(ref be) => match **be {
bdk::blockchain::esplora::EsploraError::Reqwest(_) => {
// Drop lock, sleep for a second, retry.
drop(wallet_lock);
tokio::time::sleep(Duration::from_secs(1)).await;
log_error!(
self.logger,
"Sync failed due to HTTP connection error, retrying: {}",
e
);
let sync_options = SyncOptions { progress: None };
wallet_lock
self.inner
.lock()
.unwrap()
.sync(&self.blockchain, sync_options)
.await
.map_err(|e| From::from(e))
Expand Down

0 comments on commit d070050

Please sign in to comment.