@@ -525,14 +525,14 @@ impl ChannelState {
525
525
}
526
526
}
527
527
528
- fn should_force_holding_cell (&self) -> bool {
528
+ fn can_generate_new_commitment (&self) -> bool {
529
529
match self {
530
530
ChannelState::ChannelReady(flags) =>
531
- flags.is_set(ChannelReadyFlags::AWAITING_REMOTE_REVOKE) ||
532
- flags.is_set(FundedStateFlags::MONITOR_UPDATE_IN_PROGRESS.into()) ||
533
- flags.is_set(FundedStateFlags::PEER_DISCONNECTED.into()),
531
+ ! flags.is_set(ChannelReadyFlags::AWAITING_REMOTE_REVOKE) &&
532
+ ! flags.is_set(FundedStateFlags::MONITOR_UPDATE_IN_PROGRESS.into()) &&
533
+ ! flags.is_set(FundedStateFlags::PEER_DISCONNECTED.into()),
534
534
_ => {
535
- debug_assert!(false, "The holding cell is only valid within ChannelReady");
535
+ debug_assert!(false, "Can only generate new commitment within ChannelReady");
536
536
false
537
537
},
538
538
}
@@ -2709,7 +2709,7 @@ impl<SP: Deref> Channel<SP> where
2709
2709
where L::Target: Logger {
2710
2710
// Assert that we'll add the HTLC claim to the holding cell in `get_update_fulfill_htlc`
2711
2711
// (see equivalent if condition there).
2712
- assert!(self.context.channel_state.should_force_holding_cell ());
2712
+ assert!(! self.context.channel_state.can_generate_new_commitment ());
2713
2713
let mon_update_id = self.context.latest_monitor_update_id; // Forget the ChannelMonitor update
2714
2714
let fulfill_resp = self.get_update_fulfill_htlc(htlc_id_arg, payment_preimage_arg, logger);
2715
2715
self.context.latest_monitor_update_id = mon_update_id;
@@ -2779,7 +2779,7 @@ impl<SP: Deref> Channel<SP> where
2779
2779
}],
2780
2780
};
2781
2781
2782
- if self.context.channel_state.should_force_holding_cell () {
2782
+ if ! self.context.channel_state.can_generate_new_commitment () {
2783
2783
// Note that this condition is the same as the assertion in
2784
2784
// `claim_htlc_while_disconnected_dropping_mon_update` and must match exactly -
2785
2785
// `claim_htlc_while_disconnected_dropping_mon_update` would not work correctly if we
@@ -2953,7 +2953,7 @@ impl<SP: Deref> Channel<SP> where
2953
2953
return Ok(None);
2954
2954
}
2955
2955
2956
- if self.context.channel_state.should_force_holding_cell () {
2956
+ if ! self.context.channel_state.can_generate_new_commitment () {
2957
2957
debug_assert!(force_holding_cell, "!force_holding_cell is only called when emptying the holding cell, so we shouldn't end up back in it!");
2958
2958
force_holding_cell = true;
2959
2959
}
@@ -3570,7 +3570,7 @@ impl<SP: Deref> Channel<SP> where
3570
3570
) -> (Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>)
3571
3571
where F::Target: FeeEstimator, L::Target: Logger
3572
3572
{
3573
- if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && ! self.context.channel_state.should_force_holding_cell () {
3573
+ if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && self.context.channel_state.can_generate_new_commitment () {
3574
3574
self.free_holding_cell_htlcs(fee_estimator, logger)
3575
3575
} else { (None, Vec::new()) }
3576
3576
}
@@ -5857,7 +5857,7 @@ impl<SP: Deref> Channel<SP> where
5857
5857
return Err(ChannelError::Ignore("Cannot send an HTLC while disconnected from channel counterparty".to_owned()));
5858
5858
}
5859
5859
5860
- let need_holding_cell = self.context.channel_state.should_force_holding_cell ();
5860
+ let need_holding_cell = ! self.context.channel_state.can_generate_new_commitment ();
5861
5861
log_debug!(logger, "Pushing new outbound HTLC with hash {} for {} msat {}",
5862
5862
payment_hash, amount_msat,
5863
5863
if force_holding_cell { "into holding cell" }
0 commit comments