From 2727c52d3c13d2b222bbcda1c06bf56737a4cd4f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 21 Oct 2021 19:05:48 +0000 Subject: [PATCH] Rename payment object vars to refer to payments and not session IDs --- lightning/src/ln/channelmanager.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 187a95b53..ea058c581 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3127,16 +3127,16 @@ impl ChannelMana session_priv_bytes.copy_from_slice(&session_priv[..]); let mut outbounds = self.pending_outbound_payments.lock().unwrap(); let mut all_paths_failed = false; - if let hash_map::Entry::Occupied(mut sessions) = outbounds.entry(payment_id) { - if !sessions.get_mut().remove(&session_priv_bytes, Some(path.last().unwrap().fee_msat)) { + if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) { + if !payment.get_mut().remove(&session_priv_bytes, Some(path.last().unwrap().fee_msat)) { log_trace!(self.logger, "Received duplicative fail for HTLC with payment_hash {}", log_bytes!(payment_hash.0)); return; } - if sessions.get().is_fulfilled() { + if payment.get().is_fulfilled() { log_trace!(self.logger, "Received failure of HTLC with payment_hash {} after payment completion", log_bytes!(payment_hash.0)); return; } - if sessions.get().remaining_parts() == 0 { + if payment.get().remaining_parts() == 0 { all_paths_failed = true; } } else { @@ -3390,11 +3390,11 @@ impl ChannelMana let mut session_priv_bytes = [0; 32]; session_priv_bytes.copy_from_slice(&session_priv[..]); let mut outbounds = self.pending_outbound_payments.lock().unwrap(); - if let hash_map::Entry::Occupied(mut sessions) = outbounds.entry(payment_id) { - assert!(sessions.get().is_fulfilled()); - sessions.get_mut().remove(&session_priv_bytes, None); - if sessions.get().remaining_parts() == 0 { - sessions.remove(); + if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) { + assert!(payment.get().is_fulfilled()); + payment.get_mut().remove(&session_priv_bytes, None); + if payment.get().remaining_parts() == 0 { + payment.remove(); } } } @@ -3408,9 +3408,9 @@ impl ChannelMana let mut session_priv_bytes = [0; 32]; session_priv_bytes.copy_from_slice(&session_priv[..]); let mut outbounds = self.pending_outbound_payments.lock().unwrap(); - let found_payment = if let hash_map::Entry::Occupied(mut sessions) = outbounds.entry(payment_id) { - let found_payment = !sessions.get().is_fulfilled(); - sessions.get_mut().mark_fulfilled(); + let found_payment = if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) { + let found_payment = !payment.get().is_fulfilled(); + payment.get_mut().mark_fulfilled(); if from_onchain { // We currently immediately remove HTLCs which were fulfilled on-chain. // This could potentially lead to removing a pending payment too early, @@ -3418,9 +3418,9 @@ impl ChannelMana // restart. // TODO: We should have a second monitor event that informs us of payments // irrevocably fulfilled. - sessions.get_mut().remove(&session_priv_bytes, Some(path.last().unwrap().fee_msat)); - if sessions.get().remaining_parts() == 0 { - sessions.remove(); + payment.get_mut().remove(&session_priv_bytes, Some(path.last().unwrap().fee_msat)); + if payment.get().remaining_parts() == 0 { + payment.remove(); } } found_payment -- 2.39.5