Skip to content

Commit

Permalink
f missing calls in tick
Browse files Browse the repository at this point in the history
  • Loading branch information
dunxen committed Jul 17, 2023
1 parent c446ae5 commit 1c8ef1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5489,7 +5489,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
/// A not-yet-funded outbound (from holder) channel using V1 channel establishment.
pub(super) struct OutboundV1Channel<Signer: ChannelSigner> {
pub context: ChannelContext<Signer>,
pub pending_context: UnfundedChannelContext,
pub unfunded_context: UnfundedChannelContext,
}

impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
Expand Down Expand Up @@ -5687,7 +5687,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {

blocked_monitor_updates: Vec::new(),
},
pending_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
})
}

Expand Down Expand Up @@ -5986,7 +5986,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
/// A not-yet-funded inbound (from counterparty) channel using V1 channel establishment.
pub(super) struct InboundV1Channel<Signer: ChannelSigner> {
pub context: ChannelContext<Signer>,
pub pending_context: UnfundedChannelContext,
pub unfunded_context: UnfundedChannelContext,
}

impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
Expand Down Expand Up @@ -6315,7 +6315,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {

blocked_monitor_updates: Vec::new(),
},
pending_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
};

Ok(chan)
Expand Down
34 changes: 17 additions & 17 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ use core::ops::Deref;
pub use crate::ln::outbound_payment::{PaymentSendFailure, Retry, RetryableSendFailure, RecipientOnionFields};
use crate::ln::script::ShutdownScript;

use super::channel::UnfundedChannelContext;

// We hold various information about HTLC relay in the HTLC objects in Channel itself:
//
// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should
Expand Down Expand Up @@ -4410,26 +4412,24 @@ where
true
});

let force_close_expired_unfunded_channel = |chan_id: &[u8; 32], chan_context: &mut ChannelContext<<SP::Target as SignerProvider>::Signer>| {
log_error!(self.logger, "Force-closing pending outbound channel {} for not establishing in a timely manner", log_bytes!(&chan_id[..]));
self.issue_channel_close_events(&chan_context, ClosureReason::HolderForceClosed);
self.finish_force_close_channel(chan_context.force_shutdown(false));
false
};
peer_state.outbound_v1_channel_by_id.retain(|chan_id, chan| {
if chan.pending_context.should_expire_unfunded_channel() {
force_close_expired_unfunded_channel(chan_id, &mut chan.context)
let process_unfunded_channel_tick = |
chan_id: &[u8; 32],
chan_context: &mut ChannelContext<<SP::Target as SignerProvider>::Signer>,
unfunded_chan_context: &mut UnfundedChannelContext,
| {
chan_context.maybe_expire_prev_config();
if unfunded_chan_context.should_expire_unfunded_channel() {
log_error!(self.logger, "Force-closing pending outbound channel {} for not establishing in a timely manner", log_bytes!(&chan_id[..]));
update_maps_on_chan_removal!(self, &chan_context);
self.issue_channel_close_events(&chan_context, ClosureReason::HolderForceClosed);
self.finish_force_close_channel(chan_context.force_shutdown(false));
false
} else {
true
}
});
peer_state.inbound_v1_channel_by_id.retain(|chan_id, chan| {
if chan.pending_context.should_expire_unfunded_channel() {
force_close_expired_unfunded_channel(chan_id, &mut chan.context)
} else {
true
}
});
};
peer_state.outbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context));
peer_state.inbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context));

if peer_state.ok_to_remove(true) {
pending_peers_awaiting_removal.push(counterparty_node_id);
Expand Down

0 comments on commit 1c8ef1b

Please sign in to comment.