From f09b237e151994284ba0f5acd3f3f67983c7c6ee Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:31:07 +0200 Subject: [PATCH] Immediately fetch transaction status upon subscription Immediately fetch transaction status upon subscription instead of waiting 1 minute (cherry picked from commit 5662f7fe81b1d93eed73621dd102f0fac3d59811) --- swap/src/bitcoin/wallet.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 44922dbb..98bbe2ef 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -131,8 +131,6 @@ impl Wallet { let mut last_status = None; loop { - tokio::time::sleep(Duration::from_secs(5)).await; - let new_status = match client.lock().await.status_of_script(&tx) { Ok(new_status) => new_status, Err(error) => { @@ -153,6 +151,8 @@ impl Wallet { return; } } + + tokio::time::sleep(Duration::from_secs(5)).await; } }); @@ -705,7 +705,7 @@ impl Client { electrum, blockchain, latest_block_height: BlockHeight::try_from(latest_block)?, - last_sync: Instant::now(), + last_sync: Instant::now() - interval, sync_interval: interval, script_history: Default::default(), subscriptions: Default::default(),