diff --git a/mm2src/mm2_main/src/lp_swap/maker_swap.rs b/mm2src/mm2_main/src/lp_swap/maker_swap.rs index de56ebcdd0..a5dd1ac38b 100644 --- a/mm2src/mm2_main/src/lp_swap/maker_swap.rs +++ b/mm2src/mm2_main/src/lp_swap/maker_swap.rs @@ -127,7 +127,7 @@ async fn save_my_maker_swap_event(ctx: &MmArc, swap: &MakerSwap, event: MakerSav #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct TakerNegotiationData { /// Swap message exchange version supported by remote taker peer. Optional because it is found at negotiation - pub taker_version: Option, + pub taker_msg_version: Option, pub taker_payment_locktime: u64, pub taker_pubkey: H264Json, pub maker_coin_swap_contract_addr: Option, @@ -163,7 +163,7 @@ pub struct MakerSwapData { /// Allows to recognize one SWAP from the other in the logs. #274. pub uuid: Uuid, /// Swap messages version that the remote taker supports. Optional because not known until negotiation - pub taker_version: Option, + pub taker_msg_version: Option, pub started_at: u64, pub maker_coin_start_block: u64, pub taker_coin_start_block: u64, @@ -301,7 +301,7 @@ impl MakerSwap { }, MakerSwapEvent::StartFailed(err) => self.errors.lock().push(err), MakerSwapEvent::Negotiated(data) => { - self.w().data.taker_version = Some(get_taker_version(&data)); + self.w().data.taker_msg_version = Some(get_taker_version(&data)); self.taker_payment_lock .store(data.taker_payment_locktime, Ordering::Relaxed); self.w().other_maker_coin_htlc_pub = data.other_maker_coin_htlc_pub(); @@ -586,7 +586,7 @@ impl MakerSwap { taker: self.taker.bytes.into(), secret: self.secret.into(), secret_hash: Some(self.secret_hash().into()), - taker_version: None, // not yet known before the negotiation stage + taker_msg_version: None, // not yet known before the negotiation stage started_at, lock_duration: self.payment_locktime, maker_amount: self.maker_amount.clone(), @@ -728,7 +728,7 @@ impl MakerSwap { Ok((Some(MakerSwapCommand::WaitForTakerFee), vec![ MakerSwapEvent::Negotiated(TakerNegotiationData { - taker_version: Some(remote_version), + taker_msg_version: Some(remote_version), taker_payment_locktime: taker_data.payment_locktime(), // using default to avoid misuse of this field // maker_coin_htlc_pubkey and taker_coin_htlc_pubkey must be used instead @@ -797,7 +797,7 @@ impl MakerSwap { let remote_version = self .r() .data - .taker_version + .taker_msg_version .ok_or("No swap protocol version".to_owned())?; let is_burn_active = LegacySwapFeature::is_active(LegacySwapFeature::SendToPreBurnAccount, remote_version); let dex_fee = dex_fee_from_taker_coin( @@ -1938,7 +1938,7 @@ impl MakerSavedSwap { maker_payment_lock: 0, uuid: Default::default(), started_at: 0, - taker_version: None, + taker_msg_version: None, maker_coin_start_block: 0, taker_coin_start_block: 0, maker_payment_trade_fee: None, @@ -2462,7 +2462,7 @@ pub async fn calc_max_maker_vol( /// Determine version from negotiation data if saved swap data does not store version /// (if the swap started before the upgrade to versioned negotiation message) /// In any case it is very undesirable to upgrade mm2 when any swaps are active -fn get_taker_version(negotiation_data: &TakerNegotiationData) -> u16 { negotiation_data.taker_version.unwrap_or(0) } +fn get_taker_version(negotiation_data: &TakerNegotiationData) -> u16 { negotiation_data.taker_msg_version.unwrap_or(0) } #[cfg(all(test, not(target_arch = "wasm32")))] mod maker_swap_tests { diff --git a/mm2src/mm2_main/src/lp_swap/recreate_swap_data.rs b/mm2src/mm2_main/src/lp_swap/recreate_swap_data.rs index ba35bc30d9..013f05cb45 100644 --- a/mm2src/mm2_main/src/lp_swap/recreate_swap_data.rs +++ b/mm2src/mm2_main/src/lp_swap/recreate_swap_data.rs @@ -138,7 +138,7 @@ fn recreate_maker_swap(ctx: MmArc, taker_swap: TakerSavedSwap) -> RecreateSwapRe maker_payment_lock: negotiated_event.maker_payment_locktime, uuid: started_event.uuid, started_at: started_event.started_at, - taker_version: None, + taker_msg_version: None, maker_coin_start_block: started_event.maker_coin_start_block, taker_coin_start_block: started_event.taker_coin_start_block, // Don't set the fee since the value is used when we calculate locked by other swaps amount only. @@ -159,7 +159,7 @@ fn recreate_maker_swap(ctx: MmArc, taker_swap: TakerSavedSwap) -> RecreateSwapRe // Generate `Negotiated` event let maker_negotiated_event = MakerSwapEvent::Negotiated(TakerNegotiationData { - taker_version: Some(LEGACY_SWAP_MSG_VERSION), + taker_msg_version: Some(LEGACY_SWAP_MSG_VERSION), taker_payment_locktime: started_event.taker_payment_lock, taker_pubkey: started_event.my_persistent_pub, maker_coin_swap_contract_addr: negotiated_event.maker_coin_swap_contract_addr, @@ -337,7 +337,7 @@ async fn recreate_taker_swap(ctx: MmArc, maker_swap: MakerSavedSwap) -> Recreate taker_payment_lock: negotiated_event.taker_payment_locktime, uuid: started_event.uuid, started_at: started_event.started_at, - maker_version: None, + maker_msg_version: None, maker_payment_wait: wait_for_maker_payment_conf_until(started_event.started_at, started_event.lock_duration), maker_coin_start_block: started_event.maker_coin_start_block, taker_coin_start_block: started_event.taker_coin_start_block, @@ -363,7 +363,7 @@ async fn recreate_taker_swap(ctx: MmArc, maker_swap: MakerSavedSwap) -> Recreate .or_mm_err(|| RecreateSwapError::NoSecretHash)?; let taker_negotiated_event = TakerSwapEvent::Negotiated(MakerNegotiationData { - maker_version: Some(LEGACY_SWAP_MSG_VERSION), + maker_msg_version: Some(LEGACY_SWAP_MSG_VERSION), maker_payment_locktime: started_event.maker_payment_lock, maker_pubkey: started_event.my_persistent_pub, secret_hash: secret_hash.clone(), diff --git a/mm2src/mm2_main/src/lp_swap/taker_swap.rs b/mm2src/mm2_main/src/lp_swap/taker_swap.rs index 7cad6b5dfd..78fca820b3 100644 --- a/mm2src/mm2_main/src/lp_swap/taker_swap.rs +++ b/mm2src/mm2_main/src/lp_swap/taker_swap.rs @@ -547,7 +547,7 @@ pub struct TakerSwapData { pub uuid: Uuid, pub started_at: u64, /// Swap message exchange version that the remote maker supports. Optional because not known until negotiation - pub maker_version: Option, + pub maker_msg_version: Option, pub maker_payment_wait: u64, pub maker_coin_start_block: u64, pub taker_coin_start_block: u64, @@ -651,7 +651,7 @@ pub struct TakerPaymentSpentData { #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct MakerNegotiationData { /// Swap message exchange version supported by remote maker peer. Optional because it is found at negotiation - pub maker_version: Option, + pub maker_msg_version: Option, pub maker_payment_locktime: u64, pub maker_pubkey: H264Json, pub secret_hash: BytesJson, @@ -835,7 +835,7 @@ impl TakerSwap { TakerSwapEvent::Negotiated(data) => { self.maker_payment_lock .store(data.maker_payment_locktime, Ordering::Relaxed); - self.w().data.maker_version = Some(get_maker_version(&data)); + self.w().data.maker_msg_version = Some(get_maker_version(&data)); self.w().other_maker_coin_htlc_pub = data.other_maker_coin_htlc_pub(); self.w().other_taker_coin_htlc_pub = data.other_taker_coin_htlc_pub(); self.w().secret_hash = data.secret_hash; @@ -1159,7 +1159,7 @@ impl TakerSwap { maker_coin: self.maker_coin.ticker().to_owned(), maker: self.maker.bytes.into(), started_at, - maker_version: None, // not yet known on start + maker_msg_version: None, // not yet known on start lock_duration: self.payment_locktime, maker_amount: self.maker_amount.to_decimal(), taker_amount: self.taker_amount.to_decimal(), @@ -1343,7 +1343,7 @@ impl TakerSwap { Ok((Some(TakerSwapCommand::SendTakerFee), vec![TakerSwapEvent::Negotiated( MakerNegotiationData { - maker_version: Some(remote_version), + maker_msg_version: Some(remote_version), maker_payment_locktime: maker_data.payment_locktime(), // using default to avoid misuse of this field // maker_coin_htlc_pubkey and taker_coin_htlc_pubkey must be used instead @@ -1368,7 +1368,7 @@ impl TakerSwap { let remote_version = self .r() .data - .maker_version + .maker_msg_version .ok_or("No swap protocol version".to_owned())?; let is_burn_active = LegacySwapFeature::is_active(LegacySwapFeature::SendToPreBurnAccount, remote_version); let dex_fee = dex_fee_from_taker_coin( @@ -2853,7 +2853,7 @@ pub fn max_taker_vol_from_available( /// Determine version from negotiation data if saved swap data does not store version /// (if the swap started before the upgrade to versioned negotiation message) /// In any case it is very undesirable to upgrade mm2 when any swaps are active -fn get_maker_version(negotiation_data: &MakerNegotiationData) -> u16 { negotiation_data.maker_version.unwrap_or(0) } +fn get_maker_version(negotiation_data: &MakerNegotiationData) -> u16 { negotiation_data.maker_msg_version.unwrap_or(0) } #[cfg(all(test, not(target_arch = "wasm32")))] mod taker_swap_tests {