From 5ac4593c429d9074856da9ef0b07d4f40e6182c3 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 20 Apr 2024 00:23:05 +0100 Subject: [PATCH] better fix for error --- mantis/node/src/mantis/blackbox/mod.rs | 53 ++++++++++++-------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/mantis/node/src/mantis/blackbox/mod.rs b/mantis/node/src/mantis/blackbox/mod.rs index 31868bb..06d00f8 100644 --- a/mantis/node/src/mantis/blackbox/mod.rs +++ b/mantis/node/src/mantis/blackbox/mod.rs @@ -191,37 +191,34 @@ pub async fn solve>( for pair_solution in cows_per_pair { let salt = super::cosmos::cvm::calculate_salt(signing_key, tip, pair_solution.ab.clone()); - let cvm_program = if let Some(ref cvm_glt) = cvm_glt { - let cvm_program = intent_banks_to_cvm_program( - pair_solution.clone(), - &active_orders, - cvm_glt, - router, - &salt, - ) - .await; - - if cvm_program.is_err() { - log::error!("cvm_program error: {:?}", cvm_program); - continue; - } - let cvm_program = cvm_program.expect("qed"); + // would be reasonable to do do cross chain if it solves some % of whole trade + let route = if Decider::get() { + let cvm_program = if let Some(ref cvm_glt) = cvm_glt { + let cvm_program = intent_banks_to_cvm_program( + pair_solution.clone(), + &active_orders, + cvm_glt, + router, + &salt, + ) + .await; - Some(cvm_program) - } else { - None - }; + if cvm_program.is_err() { + log::error!("cvm_program error: {:?}", cvm_program); + } + cvm_program.ok() + } else { + None + }; - // would be reasonable to do do cross chain if it solves some % of whole trade - let route = if let Some(cvm_program) = cvm_program - && Decider::get() - { - Some(CrossChainPart::new( - cvm_program, - salt.clone(), - pair_solution.optimal_price.into(), - )) + cvm_program.map(|cvm_program| { + CrossChainPart::new( + cvm_program, + salt.clone(), + pair_solution.optimal_price.into(), + ) + }) } else { None };