From dfe0862e190a05b457546d6ec7fb6e37cdcc1d8a Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Tue, 6 Feb 2024 11:00:41 +0100 Subject: [PATCH] f Streamline `max_total_opening_fee_msat` calculation --- src/event.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/event.rs b/src/event.rs index 89251e50e..f53fd7f85 100644 --- a/src/event.rs +++ b/src/event.rs @@ -382,19 +382,17 @@ where return; } - let max_total_opening_fee_msat = if let Some(max_total_opening_fee_msat) = - info.lsp_fee_limits.and_then(|l| l.max_total_opening_fee_msat) - { - max_total_opening_fee_msat - } else if let Some(max_proportional_opening_fee_ppm_msat) = - info.lsp_fee_limits.and_then(|l| l.max_proportional_opening_fee_ppm_msat) - { - // If it's a variable amount payment, compute the actual total opening fee. - compute_opening_fee(amount_msat, 0, max_proportional_opening_fee_ppm_msat) - .unwrap_or(0) - } else { - 0 - }; + let max_total_opening_fee_msat = info + .lsp_fee_limits + .and_then(|l| { + l.max_total_opening_fee_msat.or_else(|| { + l.max_proportional_opening_fee_ppm_msat.and_then(|max_prop_fee| { + // If it's a variable amount payment, compute the actual fee. + compute_opening_fee(amount_msat, 0, max_prop_fee) + }) + }) + }) + .unwrap_or(0); if counterparty_skimmed_fee_msat > max_total_opening_fee_msat { log_info!(