Skip to content

Commit

Permalink
Fixes (review, build)
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Dec 4, 2024
1 parent edffca2 commit dd19f65
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
{
#[inline]
pub fn context(&'a self) -> &'a ChannelContext<SP> {
pub fn context(&self) -> &ChannelContext<SP> {
match self {
ChannelPhase::Funded(chan) => &chan.context,
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
Expand All @@ -1151,7 +1151,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
}

#[inline]
pub fn context_mut(&'a mut self) -> &'a mut ChannelContext<SP> {
pub fn context_mut(&mut self) -> &mut ChannelContext<SP> {
match self {
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
Expand Down Expand Up @@ -1194,7 +1194,7 @@ impl<'a, SP: Deref> ChannelWrapper<SP> where SP::Target: SignerProvider {
}
}

pub fn get_funded_channel(&self) -> Option<&Channel<SP>> {
pub fn funded_channel(&self) -> Option<&Channel<SP>> {
if let ChannelPhase::Funded(chan) = &self.phase.as_ref().unwrap() {
Some(chan)
} else {
Expand Down Expand Up @@ -1223,12 +1223,12 @@ impl<'a, SP: Deref> ChannelWrapper<SP> where SP::Target: SignerProvider {
}

#[inline]
pub fn context(&'a self) -> &'a ChannelContext<SP> {
pub fn context(&self) -> &ChannelContext<SP> {
self.phase().context()
}

#[inline]
pub fn context_mut(&'a mut self) -> &'a mut ChannelContext<SP> {
pub fn context_mut(&mut self) -> &mut ChannelContext<SP> {
self.phase_mut().context_mut()
}
}
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}}
Expand Down
14 changes: 7 additions & 7 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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![];
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dd19f65

Please sign in to comment.