From fa047751888547f0ae43b7efbb9ae8ba37f53a43 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Wed, 24 Feb 2021 17:36:37 +1100 Subject: [PATCH] Rename function explicit to cancellation to cancel For transitioning to state4 we either go into a redeem or a cancellation scenario. The function name state4 is misleading, because it is only used for cancellation scenarios. --- swap/src/protocol/bob/cancel.rs | 4 ++-- swap/src/protocol/bob/refund.rs | 4 ++-- swap/src/protocol/bob/state.rs | 2 +- swap/src/protocol/bob/swap.rs | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/swap/src/protocol/bob/cancel.rs b/swap/src/protocol/bob/cancel.rs index ccce6361..dab0fc79 100644 --- a/swap/src/protocol/bob/cancel.rs +++ b/swap/src/protocol/bob/cancel.rs @@ -23,8 +23,8 @@ pub async fn cancel( force: bool, ) -> Result> { let state4 = match state { - BobState::BtcLocked(state3) => state3.state4(), - BobState::XmrLockProofReceived { state, .. } => state.state4(), + BobState::BtcLocked(state3) => state3.cancel(), + BobState::XmrLockProofReceived { state, .. } => state.cancel(), BobState::XmrLocked(state4) => state4, BobState::EncSigSent(state4) => state4, BobState::CancelTimelockExpired(state4) => state4, diff --git a/swap/src/protocol/bob/refund.rs b/swap/src/protocol/bob/refund.rs index b341dad2..8536eed0 100644 --- a/swap/src/protocol/bob/refund.rs +++ b/swap/src/protocol/bob/refund.rs @@ -22,8 +22,8 @@ pub async fn refund( ) -> Result> { let state4 = if force { match state { - BobState::BtcLocked(state3) => state3.state4(), - BobState::XmrLockProofReceived { state, .. } => state.state4(), + BobState::BtcLocked(state3) => state3.cancel(), + BobState::XmrLockProofReceived { state, .. } => state.cancel(), BobState::XmrLocked(state4) => state4, BobState::EncSigSent(state4) => state4, BobState::CancelTimelockExpired(state4) => state4, diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 0d6349e7..91930cdf 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -379,7 +379,7 @@ impl State3 { .await } - pub fn state4(&self) -> State4 { + pub fn cancel(&self) -> State4 { State4 { A: self.A, b: self.b.clone(), diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 628462cc..ba91dbfa 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -141,12 +141,12 @@ async fn run_until_internal( } }, _ = cancel_timelock_expires => { - let state4 = state3.state4(); + let state4 = state3.cancel(); BobState::CancelTimelockExpired(state4) } } } else { - let state4 = state3.state4(); + let state4 = state3.cancel(); BobState::CancelTimelockExpired(state4) }; let db_state = state.clone().into(); @@ -188,18 +188,18 @@ async fn run_until_internal( Err(InsufficientFunds {..}) => { info!("The other party has locked insufficient Monero funds! Waiting for refund..."); state.wait_for_cancel_timelock_to_expire(bitcoin_wallet.as_ref()).await?; - let state4 = state.state4(); + let state4 = state.cancel(); BobState::CancelTimelockExpired(state4) }, } }, _ = cancel_timelock_expires => { - let state4 = state.state4(); + let state4 = state.cancel(); BobState::CancelTimelockExpired(state4) } } } else { - let state4 = state.state4(); + let state4 = state.cancel(); BobState::CancelTimelockExpired(state4) };