@@ -3119,9 +3119,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3119
3119
3120
3120
let mut htlc_updates = Vec::new();
3121
3121
mem::swap(&mut htlc_updates, &mut self.context.holding_cell_htlc_updates);
3122
- let mut update_add_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3123
- let mut update_fulfill_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3124
- let mut update_fail_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3122
+ let mut update_add_count = 0 ;
3123
+ let mut update_fulfill_count = 0 ;
3124
+ let mut update_fail_count = 0 ;
3125
3125
let mut htlcs_to_fail = Vec::new();
3126
3126
for htlc_update in htlc_updates.drain(..) {
3127
3127
// Note that this *can* fail, though it should be due to rather-rare conditions on
@@ -3137,7 +3137,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3137
3137
match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
3138
3138
onion_routing_packet.clone(), false, skimmed_fee_msat, fee_estimator, logger)
3139
3139
{
3140
- Ok(update_add_msg_option ) => update_add_htlcs.push(update_add_msg_option.unwrap()) ,
3140
+ Ok(_ ) => update_add_count += 1 ,
3141
3141
Err(e) => {
3142
3142
match e {
3143
3143
ChannelError::Ignore(ref msg) => {
@@ -3164,11 +3164,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3164
3164
// not fail - any in between attempts to claim the HTLC will have resulted
3165
3165
// in it hitting the holding cell again and we cannot change the state of a
3166
3166
// holding cell HTLC from fulfill to anything else.
3167
- let (update_fulfill_msg_option, mut additional_monitor_update) =
3168
- if let UpdateFulfillFetch::NewClaim { msg, monitor_update, .. } = self.get_update_fulfill_htlc(htlc_id, *payment_preimage, logger) {
3169
- (msg, monitor_update )
3170
- } else { unreachable!() };
3171
- update_fulfill_htlcs.push(update_fulfill_msg_option.unwrap()) ;
3167
+ let mut additional_monitor_update =
3168
+ if let UpdateFulfillFetch::NewClaim { monitor_update, .. } =
3169
+ self.get_update_fulfill_htlc(htlc_id, *payment_preimage, logger )
3170
+ { monitor_update } else { unreachable!() };
3171
+ update_fulfill_count += 1 ;
3172
3172
monitor_update.updates.append(&mut additional_monitor_update.updates);
3173
3173
},
3174
3174
&HTLCUpdateAwaitingACK::FailHTLC { htlc_id, ref err_packet } => {
@@ -3179,7 +3179,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3179
3179
// not fail - we should never end up in a state where we double-fail
3180
3180
// an HTLC or fail-then-claim an HTLC as it indicates we didn't wait
3181
3181
// for a full revocation before failing.
3182
- update_fail_htlcs.push(update_fail_msg_option.unwrap())
3182
+ debug_assert!(update_fail_msg_option.is_some());
3183
+ update_fail_count += 1;
3183
3184
},
3184
3185
Err(e) => {
3185
3186
if let ChannelError::Ignore(_) = e {}
@@ -3191,7 +3192,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3191
3192
},
3192
3193
}
3193
3194
}
3194
- if update_add_htlcs.is_empty() && update_fulfill_htlcs.is_empty() && update_fail_htlcs.is_empty() && self.context.holding_cell_update_fee.is_none() {
3195
+ if update_add_count == 0 && update_fulfill_count == 0 && update_fail_count == 0 && self.context.holding_cell_update_fee.is_none() {
3195
3196
return (None, htlcs_to_fail);
3196
3197
}
3197
3198
let update_fee = if let Some(feerate) = self.context.holding_cell_update_fee.take() {
@@ -3208,7 +3209,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3208
3209
3209
3210
log_debug!(logger, "Freeing holding cell in channel {} resulted in {}{} HTLCs added, {} HTLCs fulfilled, and {} HTLCs failed.",
3210
3211
log_bytes!(self.context.channel_id()), if update_fee.is_some() { "a fee update, " } else { "" },
3211
- update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len() );
3212
+ update_add_count, update_fulfill_count, update_fail_count );
3212
3213
3213
3214
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
3214
3215
(self.push_ret_blockable_mon_update(monitor_update), htlcs_to_fail)
0 commit comments