Skip to content

Commit

Permalink
review: use if let Some
Browse files Browse the repository at this point in the history
  • Loading branch information
laruh committed Dec 24, 2024
1 parent 1065997 commit c214726
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions mm2src/mm2_main/src/lp_swap/swap_v2_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,32 +379,29 @@ pub(super) async fn swap_kickstart_handler_for_maker(
storage: MakerSwapStorage,
uuid: Uuid,
) {
let (maker_coin, taker_coin) = match swap_kickstart_coins(&ctx, &swap_repr, &uuid).await {
Some(coins) => coins,
None => return,
};

match (maker_coin, taker_coin) {
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
_ => {
error!(
"V2 swaps are not currently supported for {}/{} pair",
swap_repr.maker_coin(),
swap_repr.taker_coin()
);
},
};
if let Some((maker_coin, taker_coin)) = swap_kickstart_coins(&ctx, &swap_repr, &uuid).await {
match (maker_coin, taker_coin) {
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<MakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
_ => {
error!(
"V2 swaps are not currently supported for {}/{} pair",
swap_repr.maker_coin(),
swap_repr.taker_coin()
);
},
}
}
}

pub(super) async fn swap_kickstart_handler_for_taker(
Expand All @@ -413,30 +410,27 @@ pub(super) async fn swap_kickstart_handler_for_taker(
storage: TakerSwapStorage,
uuid: Uuid,
) {
let (maker_coin, taker_coin) = match swap_kickstart_coins(&ctx, &swap_repr, &uuid).await {
Some(coins) => coins,
None => return,
};

match (maker_coin, taker_coin) {
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
_ => {
error!(
"V2 swaps are not currently supported for {}/{} pair",
swap_repr.maker_coin(),
swap_repr.taker_coin()
);
},
};
if let Some((maker_coin, taker_coin)) = swap_kickstart_coins(&ctx, &swap_repr, &uuid).await {
match (maker_coin, taker_coin) {
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::UtxoCoin(m), MmCoinEnum::EthCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
(MmCoinEnum::EthCoin(m), MmCoinEnum::UtxoCoin(t)) => {
swap_kickstart_handler::<TakerSwapStateMachine<_, _>, _, _>(swap_repr, storage, uuid, m, t).await
},
_ => {
error!(
"V2 swaps are not currently supported for {}/{} pair",
swap_repr.maker_coin(),
swap_repr.taker_coin()
);
},
}
}
}

0 comments on commit c214726

Please sign in to comment.