Skip to content

Commit

Permalink
Merge pull request #13 from getAlby/chore/update-anchor-support-2
Browse files Browse the repository at this point in the history
Chore: update anchor support 2
  • Loading branch information
rolznz authored Mar 18, 2024
2 parents 7d03cef + 30a842d commit 6477bab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bindings/python/src/ldk_node/test_ldk_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_channel_full_cycle(self):
print("EVENT:", payment_received_event_2)
node_2.event_handled()

node_2.close_channel(channel_ready_event_2.user_channel_id, node_id_1, false)
node_2.close_channel(channel_ready_event_2.user_channel_id, node_id_1, False)

channel_closed_event_1 = node_1.wait_next_event()
assert isinstance(channel_closed_event_1, Event.CHANNEL_CLOSED)
Expand Down
14 changes: 10 additions & 4 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ where
blockchain: EsploraBlockchain, wallet: bdk::Wallet<D>, broadcaster: B, fee_estimator: E,
logger: L,
) -> Self {
let inner = Mutex::new(wallet);
let sync_lock = (Mutex::new(()), Condvar::new());
let balance_cache = RwLock::new(Balance {
let start_balance = wallet.get_balance().unwrap_or(Balance {
immature: 0,
trusted_pending: 0,
untrusted_pending: 0,
confirmed: 0,
});

let inner = Mutex::new(wallet);
let sync_lock = (Mutex::new(()), Condvar::new());
let balance_cache = RwLock::new(start_balance);
Self { blockchain, inner, broadcaster, fee_estimator, sync_lock, balance_cache, logger }
}

Expand Down Expand Up @@ -107,14 +109,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 6477bab

Please sign in to comment.