diff --git a/mm2src/mm2_main/src/lp_native_dex.rs b/mm2src/mm2_main/src/lp_native_dex.rs index 4dd4a49e85..3af6d231f1 100644 --- a/mm2src/mm2_main/src/lp_native_dex.rs +++ b/mm2src/mm2_main/src/lp_native_dex.rs @@ -52,7 +52,8 @@ use crate::lp_message_service::{init_message_service, InitMessageServiceError}; use crate::lp_network::{lp_network_ports, p2p_event_process_loop, subscribe_to_topic, NetIdError}; use crate::lp_ordermatch::{broadcast_maker_orders_keep_alive_loop, clean_memory_loop, init_ordermatch_context, lp_ordermatch_loop, orders_kick_start, BalanceUpdateOrdermatchHandler, OrdermatchInitError}; -use crate::lp_swap::{running_swaps_num, swap_kick_starts}; +use crate::lp_swap; +use crate::lp_swap::swap_kick_starts; use crate::lp_wallet::{initialize_wallet_passphrase, WalletInitError}; use crate::rpc::spawn_rpc; @@ -535,6 +536,7 @@ pub async fn lp_init(ctx: MmArc, version: String, datetime: String) -> MmInitRes }; Timer::sleep(0.2).await } + lp_swap::clear_running_swaps(&ctx); Ok(()) } diff --git a/mm2src/mm2_main/src/lp_swap.rs b/mm2src/mm2_main/src/lp_swap.rs index f64b64e13c..d2990e6e25 100644 --- a/mm2src/mm2_main/src/lp_swap.rs +++ b/mm2src/mm2_main/src/lp_swap.rs @@ -655,10 +655,9 @@ pub fn get_locked_amount(ctx: &MmArc, coin: &str) -> MmNumber { } /// Get number of currently running swaps -pub fn running_swaps_num(ctx: &MmArc) -> u64 { +pub fn clear_running_swaps(ctx: &MmArc) { let swap_ctx = SwapsContext::from_ctx(ctx).unwrap(); - let count = swap_ctx.running_swaps.lock().unwrap().len(); - count as u64 + swap_ctx.running_swaps.lock().unwrap().clear(); } /// Get total amount of selected coin locked by all currently ongoing swaps except the one with selected uuid