From dd19f65f731c3dbd8dab527c3e63f9871b5e73d0 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:18:55 +0100 Subject: [PATCH] Fixes (review, build) --- lightning/src/ln/channel.rs | 10 +++++----- lightning/src/ln/channelmanager.rs | 8 ++++---- lightning/src/ln/functional_test_utils.rs | 2 +- lightning/src/ln/functional_tests.rs | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index b7e62aa236d..79b745585a8 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1140,7 +1140,7 @@ impl<'a, SP: Deref> ChannelPhase where ::EcdsaSigner: ChannelSigner, { #[inline] - pub fn context(&'a self) -> &'a ChannelContext { + pub fn context(&self) -> &ChannelContext { match self { ChannelPhase::Funded(chan) => &chan.context, ChannelPhase::UnfundedOutboundV1(chan) => &chan.context, @@ -1151,7 +1151,7 @@ impl<'a, SP: Deref> ChannelPhase where } #[inline] - pub fn context_mut(&'a mut self) -> &'a mut ChannelContext { + pub fn context_mut(&mut self) -> &mut ChannelContext { match self { ChannelPhase::Funded(ref mut chan) => &mut chan.context, ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context, @@ -1194,7 +1194,7 @@ impl<'a, SP: Deref> ChannelWrapper where SP::Target: SignerProvider { } } - pub fn get_funded_channel(&self) -> Option<&Channel> { + pub fn funded_channel(&self) -> Option<&Channel> { if let ChannelPhase::Funded(chan) = &self.phase.as_ref().unwrap() { Some(chan) } else { @@ -1223,12 +1223,12 @@ impl<'a, SP: Deref> ChannelWrapper where SP::Target: SignerProvider { } #[inline] - pub fn context(&'a self) -> &'a ChannelContext { + pub fn context(&self) -> &ChannelContext { self.phase().context() } #[inline] - pub fn context_mut(&'a mut self) -> &'a mut ChannelContext { + pub fn context_mut(&mut self) -> &mut ChannelContext { self.phase_mut().context_mut() } } diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 846e77c0d4c..61410aa395d 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -9527,7 +9527,7 @@ where peer_state.channel_by_id.retain(|_, chan| { let shutdown_result = match channel_opt { Some((_, channel_id)) if chan.context().channel_id() != channel_id => None, - _ => unblock_chan(chan, &mut peer_state.pending_msg_events), + _ => unblock_chan(chan.phase_mut(), &mut peer_state.pending_msg_events), }; if let Some(shutdown_result) = shutdown_result { let context = &chan.context(); @@ -10531,7 +10531,7 @@ where let mut peer_state_lock = peer_state_mutex.lock().unwrap(); let peer_state = &mut *peer_state_lock; for chan in peer_state.channel_by_id.values().filter_map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ) { for (htlc_source, _) in chan.inflight_htlc_sources() { if let HTLCSource::OutboundRoute { path, .. } = htlc_source { @@ -10907,7 +10907,7 @@ where for (_cp_id, peer_state_mutex) in self.per_peer_state.read().unwrap().iter() { let mut peer_state_lock = peer_state_mutex.lock().unwrap(); let peer_state = &mut *peer_state_lock; - for chan in peer_state.channel_by_id.values().filter_map(|channel| channel.get_funded_channel()) { + for chan in peer_state.channel_by_id.values().filter_map(|channel| channel.funded_channel()) { let txid_opt = chan.context.get_funding_txo(); let height_opt = chan.context.get_funding_tx_confirmation_height(); let hash_opt = chan.context.get_funding_tx_confirmed_in(); @@ -12725,7 +12725,7 @@ where } number_of_funded_channels += peer_state.channel_by_id.iter().filter( - |(_, channel)| channel.get_funded_channel().map(|chan| chan.context.is_funding_broadcast()).unwrap_or(false) + |(_, channel)| channel.funded_channel().map(|chan| chan.context.is_funding_broadcast()).unwrap_or(false) ).count(); } diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 653a1642c6c..19ddc19dc5b 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -3618,7 +3618,7 @@ macro_rules! get_channel_value_stat { let peer_state_lock = $node.node.per_peer_state.read().unwrap(); let chan_lock = peer_state_lock.get(&$counterparty_node.node.get_our_node_id()).unwrap().lock().unwrap(); let chan = chan_lock.channel_by_id.get(&$channel_id).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); chan.get_value_stat() }} diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 936781310ed..a9b1ee2e654 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -735,7 +735,7 @@ fn test_update_fee_that_funder_cannot_afford() { let per_peer_state = nodes[0].node.per_peer_state.read().unwrap(); let chan_lock = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap(); let local_chan = chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let chan_signer = local_chan.get_signer(); let pubkeys = chan_signer.as_ref().pubkeys(); @@ -746,7 +746,7 @@ fn test_update_fee_that_funder_cannot_afford() { let per_peer_state = nodes[1].node.per_peer_state.read().unwrap(); let chan_lock = per_peer_state.get(&nodes[0].node.get_our_node_id()).unwrap().lock().unwrap(); let remote_chan = chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let chan_signer = remote_chan.get_signer(); let pubkeys = chan_signer.as_ref().pubkeys(); @@ -763,7 +763,7 @@ fn test_update_fee_that_funder_cannot_afford() { let per_peer_state = nodes[0].node.per_peer_state.read().unwrap(); let local_chan_lock = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap(); let local_chan = local_chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let local_chan_signer = local_chan.get_signer(); let mut htlcs: Vec<(HTLCOutputInCommitment, ())> = vec![]; @@ -1467,7 +1467,7 @@ fn test_fee_spike_violation_fails_htlc() { let per_peer_state = nodes[0].node.per_peer_state.read().unwrap(); let chan_lock = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap(); let local_chan = chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let chan_signer = local_chan.get_signer(); // Make the signer believe we validated another commitment, so we can release the secret @@ -1483,7 +1483,7 @@ fn test_fee_spike_violation_fails_htlc() { let per_peer_state = nodes[1].node.per_peer_state.read().unwrap(); let chan_lock = per_peer_state.get(&nodes[0].node.get_our_node_id()).unwrap().lock().unwrap(); let remote_chan = chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let chan_signer = remote_chan.get_signer(); let pubkeys = chan_signer.as_ref().pubkeys(); @@ -1514,7 +1514,7 @@ fn test_fee_spike_violation_fails_htlc() { let per_peer_state = nodes[0].node.per_peer_state.read().unwrap(); let local_chan_lock = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap(); let local_chan = local_chan_lock.channel_by_id.get(&chan.2).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap(); let local_chan_signer = local_chan.get_signer(); let commitment_tx = CommitmentTransaction::new_with_auxiliary_htlc_data( @@ -7868,7 +7868,7 @@ fn test_counterparty_raa_skip_no_crash() { let per_peer_state = nodes[0].node.per_peer_state.read().unwrap(); let mut guard = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap(); let keys = guard.channel_by_id.get_mut(&channel_id).map( - |channel| channel.get_funded_channel() + |channel| channel.funded_channel() ).flatten().unwrap().get_signer(); const INITIAL_COMMITMENT_NUMBER: u64 = (1 << 48) - 1;