From c68e282a4fbfd7e0c7f4c2140bb33980d8cc7166 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Thu, 25 Jul 2024 14:57:30 +0200 Subject: [PATCH] feat: Retry by abusing state machine --- swap/src/protocol/alice/swap.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 79236563..8a0f1424 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -119,12 +119,22 @@ where let transfer_proof = monero_wallet .transfer(state3.lock_xmr_transfer_request()) - .await?; + .await; - AliceState::XmrLockTransactionSent { - monero_wallet_restore_blockheight, - transfer_proof, - state3, + match transfer_proof { + Ok(transfer_proof) => { + AliceState::XmrLockTransactionSent { + monero_wallet_restore_blockheight, + transfer_proof, + state3, + } + } + Err(e) => { + tracing::error!("Failed to lock XMR: {:#}", e); + // Sleep 10seconds + tokio::time::sleep(std::time::Duration::from_secs(10)).await; + AliceState::BtcLocked { state3 } + } } } _ => AliceState::SafelyAborted,