Skip to content

Commit

Permalink
refactor(MarketCoinOps): make wait_for_htlc_tx_spend async (#2265)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamardy authored and Alrighttt committed Nov 26, 2024
1 parent d187519 commit 121ea05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion mm2src/coins/siacoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ impl MarketCoinOps for SiaCoin {
let client = self.client.clone();
let tx_request = GetEventRequest { txid: txid.clone() };

let fut = async move {
loop {
if now_sec() > input.wait_until {
return ERR!(
Expand Down
25 changes: 14 additions & 11 deletions mm2src/mm2_main/src/lp_swap/swap_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,20 @@ impl State for WaitForTakerPaymentSpend {
},
};

let f = watcher_ctx.maker_coin.wait_for_htlc_tx_spend(WaitForHTLCTxSpendArgs {
tx_bytes: &maker_payment_hex,
secret_hash: &watcher_ctx.data.secret_hash,
wait_until,
from_block: watcher_ctx.data.maker_coin_start_block,
swap_contract_address: &None,
check_every: payment_search_interval,
watcher_reward: watcher_ctx.watcher_reward,
});

if f.await.is_ok() {
if watcher_ctx
.maker_coin
.wait_for_htlc_tx_spend(WaitForHTLCTxSpendArgs {
tx_bytes: &maker_payment_hex,
secret_hash: &watcher_ctx.data.secret_hash,
wait_until,
from_block: watcher_ctx.data.maker_coin_start_block,
swap_contract_address: &None,
check_every: payment_search_interval,
watcher_reward: watcher_ctx.watcher_reward,
})
.await
.is_ok()
{
info!("{}", MAKER_PAYMENT_SPEND_FOUND_LOG);
return Self::change_state(Stopped::from_reason(StopReason::Finished(
WatcherSuccess::MakerPaymentSpentByTaker,
Expand Down

0 comments on commit 121ea05

Please sign in to comment.