@@ -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
}
@@ -2699,7 +2699,7 @@ impl<SP: Deref> Channel<SP> where
2699
2699
where L::Target: Logger {
2700
2700
// Assert that we'll add the HTLC claim to the holding cell in `get_update_fulfill_htlc`
2701
2701
// (see equivalent if condition there).
2702
- assert!(self.context.channel_state.should_force_holding_cell ());
2702
+ assert!(! self.context.channel_state.can_generate_new_commitment ());
2703
2703
let mon_update_id = self.context.latest_monitor_update_id; // Forget the ChannelMonitor update
2704
2704
let fulfill_resp = self.get_update_fulfill_htlc(htlc_id_arg, payment_preimage_arg, logger);
2705
2705
self.context.latest_monitor_update_id = mon_update_id;
@@ -2768,7 +2768,7 @@ impl<SP: Deref> Channel<SP> where
2768
2768
}],
2769
2769
};
2770
2770
2771
- if self.context.channel_state.should_force_holding_cell () {
2771
+ if ! self.context.channel_state.can_generate_new_commitment () {
2772
2772
// Note that this condition is the same as the assertion in
2773
2773
// `claim_htlc_while_disconnected_dropping_mon_update` and must match exactly -
2774
2774
// `claim_htlc_while_disconnected_dropping_mon_update` would not work correctly if we
@@ -2942,7 +2942,7 @@ impl<SP: Deref> Channel<SP> where
2942
2942
return Ok(None);
2943
2943
}
2944
2944
2945
- if self.context.channel_state.should_force_holding_cell () {
2945
+ if ! self.context.channel_state.can_generate_new_commitment () {
2946
2946
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!");
2947
2947
force_holding_cell = true;
2948
2948
}
@@ -3544,7 +3544,7 @@ impl<SP: Deref> Channel<SP> where
3544
3544
) -> (Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>)
3545
3545
where F::Target: FeeEstimator, L::Target: Logger
3546
3546
{
3547
- if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && ! self.context.channel_state.should_force_holding_cell () {
3547
+ if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && self.context.channel_state.can_generate_new_commitment () {
3548
3548
self.free_holding_cell_htlcs(fee_estimator, logger)
3549
3549
} else { (None, Vec::new()) }
3550
3550
}
@@ -5821,7 +5821,7 @@ impl<SP: Deref> Channel<SP> where
5821
5821
return Err(ChannelError::Ignore("Cannot send an HTLC while disconnected from channel counterparty".to_owned()));
5822
5822
}
5823
5823
5824
- let need_holding_cell = self.context.channel_state.should_force_holding_cell ();
5824
+ let need_holding_cell = ! self.context.channel_state.can_generate_new_commitment ();
5825
5825
log_debug!(logger, "Pushing new outbound HTLC with hash {} for {} msat {}",
5826
5826
payment_hash, amount_msat,
5827
5827
if force_holding_cell { "into holding cell" }
0 commit comments