@@ -3119,9 +3119,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31193119
31203120 let mut htlc_updates = Vec::new();
31213121 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 ;
31253125 let mut htlcs_to_fail = Vec::new();
31263126 for htlc_update in htlc_updates.drain(..) {
31273127 // Note that this *can* fail, though it should be due to rather-rare conditions on
@@ -3137,7 +3137,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31373137 match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
31383138 onion_routing_packet.clone(), false, skimmed_fee_msat, fee_estimator, logger)
31393139 {
3140- Ok(update_add_msg_option ) => update_add_htlcs.push(update_add_msg_option.unwrap()) ,
3140+ Ok(_ ) => update_add_count += 1 ,
31413141 Err(e) => {
31423142 match e {
31433143 ChannelError::Ignore(ref msg) => {
@@ -3164,11 +3164,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31643164 // not fail - any in between attempts to claim the HTLC will have resulted
31653165 // in it hitting the holding cell again and we cannot change the state of a
31663166 // 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 ;
31723172 monitor_update.updates.append(&mut additional_monitor_update.updates);
31733173 },
31743174 &HTLCUpdateAwaitingACK::FailHTLC { htlc_id, ref err_packet } => {
@@ -3179,7 +3179,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31793179 // not fail - we should never end up in a state where we double-fail
31803180 // an HTLC or fail-then-claim an HTLC as it indicates we didn't wait
31813181 // 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;
31833184 },
31843185 Err(e) => {
31853186 if let ChannelError::Ignore(_) = e {}
@@ -3191,7 +3192,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31913192 },
31923193 }
31933194 }
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() {
31953196 return (None, htlcs_to_fail);
31963197 }
31973198 let update_fee = if let Some(feerate) = self.context.holding_cell_update_fee.take() {
@@ -3208,7 +3209,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
32083209
32093210 log_debug!(logger, "Freeing holding cell in channel {} resulted in {}{} HTLCs added, {} HTLCs fulfilled, and {} HTLCs failed.",
32103211 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 );
32123213
32133214 self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
32143215 (self.push_ret_blockable_mon_update(monitor_update), htlcs_to_fail)
0 commit comments