Skip to content

Commit

Permalink
review: make SwapVersion::version u8
Browse files Browse the repository at this point in the history
  • Loading branch information
laruh committed Feb 5, 2025
1 parent e833c27 commit bab63f1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions mm2src/mm2_main/src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const TRIE_ORDER_HISTORY_TIMEOUT: u64 = 300;
#[cfg(test)]
const TRIE_ORDER_HISTORY_TIMEOUT: u64 = 3;
/// Current swap protocol version
const SWAP_VERSION: u32 = 2;
const SWAP_VERSION: u8 = 2;

pub type OrderbookP2PHandlerResult = Result<(), MmError<OrderbookP2PHandlerError>>;

Expand Down Expand Up @@ -1267,7 +1267,7 @@ pub struct TakerOrderBuilder<'a> {
min_volume: Option<MmNumber>,
timeout: u64,
save_in_history: bool,
swap_version: u32,
swap_version: u8,
}

pub enum TakerOrderBuildError {
Expand Down Expand Up @@ -1723,7 +1723,7 @@ pub struct MakerOrderBuilder<'a> {
rel_orderbook_ticker: Option<String>,
conf_settings: Option<OrderConfirmationsSettings>,
save_in_history: bool,
swap_version: u32,
swap_version: u8,
}

pub enum MakerOrderBuildError {
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_main/src/lp_swap/maker_swap_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub struct MakerSwapDbRepr {
/// Taker's P2P pubkey
pub taker_p2p_pub: Secp256k1PubkeySerialize,
/// Swap protocol version
pub swap_version: u32,
pub swap_version: u8,
}

impl StateMachineDbRepr for MakerSwapDbRepr {
Expand Down Expand Up @@ -397,7 +397,7 @@ pub struct MakerSwapStateMachine<MakerCoin: MmCoin + MakerCoinSwapOpsV2, TakerCo
/// Determines if the taker payment spend transaction must be confirmed before marking swap as Completed.
pub require_taker_payment_spend_confirm: bool,
/// Swap protocol version
pub swap_version: u32,
pub swap_version: u8,
}

impl<MakerCoin: MmCoin + MakerCoinSwapOpsV2, TakerCoin: MmCoin + TakerCoinSwapOpsV2>
Expand Down
2 changes: 1 addition & 1 deletion mm2src/mm2_main/src/lp_swap/swap_v2_rpcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub(crate) struct MySwapForRpc<T> {
maker_coin_nota: bool,
taker_coin_confs: i64,
taker_coin_nota: bool,
swap_version: u32,
swap_version: u8,
}

impl<T: DeserializeOwned> MySwapForRpc<T> {
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub struct TakerSwapDbRepr {
/// Maker's P2P pubkey
pub maker_p2p_pub: Secp256k1PubkeySerialize,
/// Swap protocol version
pub swap_version: u32,
pub swap_version: u8,
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -429,7 +429,7 @@ pub struct TakerSwapStateMachine<MakerCoin: MmCoin + MakerCoinSwapOpsV2, TakerCo
/// Determines if the maker payment spend transaction must be confirmed before marking swap as Completed.
pub require_maker_payment_spend_confirm: bool,
/// Swap protocol version
pub swap_version: u32,
pub swap_version: u8,
}

impl<MakerCoin: MmCoin + MakerCoinSwapOpsV2, TakerCoin: MmCoin + TakerCoinSwapOpsV2>
Expand Down
8 changes: 4 additions & 4 deletions mm2src/mm2_main/src/swap_versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct SwapVersion {
pub version: u32,
pub version: u8,
}

impl Default for SwapVersion {
Expand All @@ -19,8 +19,8 @@ impl SwapVersion {
pub(crate) const fn is_legacy(&self) -> bool { self.version == legacy_swap_version() }
}

impl From<u32> for SwapVersion {
fn from(version: u32) -> Self { Self { version } }
impl From<u8> for SwapVersion {
fn from(version: u8) -> Self { Self { version } }
}

pub(crate) const fn legacy_swap_version() -> u32 { 1 }
pub(crate) const fn legacy_swap_version() -> u8 { 1 }

0 comments on commit bab63f1

Please sign in to comment.