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.
This commit is contained in:
Daniel Karzel 2021-02-24 17:36:37 +11:00
parent 1404057dbe
commit fa04775188
4 changed files with 10 additions and 10 deletions

View File

@ -23,8 +23,8 @@ pub async fn cancel(
force: bool,
) -> Result<Result<(Txid, BobState), CancelError>> {
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,

View File

@ -22,8 +22,8 @@ pub async fn refund(
) -> Result<Result<BobState, SwapNotCancelledYet>> {
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,

View File

@ -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(),

View File

@ -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)
};