Simplify code within BobState::XmrLocked

By reducing the number of local variables, we can greatly simplify
this piece of code.
This commit is contained in:
Thomas Eizinger 2021-03-18 13:34:46 +11:00
parent 776a50137d
commit 09e2d5b5d7
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -178,21 +178,12 @@ async fn run_until_internal(
event_loop_handle.dial().await?;
// Alice has locked Xmr
// Bob sends Alice his key
let tx_redeem_encsig = state.tx_redeem_encsig();
let state4_clone = state.clone();
let enc_sig_sent_watcher =
event_loop_handle.send_encrypted_signature(tx_redeem_encsig);
let bitcoin_wallet = bitcoin_wallet.clone();
let cancel_timelock_expires =
state4_clone.wait_for_cancel_timelock_to_expire(bitcoin_wallet.as_ref());
select! {
_ = enc_sig_sent_watcher => {
_ = event_loop_handle.send_encrypted_signature(state.tx_redeem_encsig()) => {
BobState::EncSigSent(state)
},
_ = cancel_timelock_expires => {
_ = state.wait_for_cancel_timelock_to_expire(bitcoin_wallet.as_ref()) => {
BobState::CancelTimelockExpired(state)
}
}