@@ -3077,9 +3077,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30773077
30783078 let mut htlc_updates = Vec::new();
30793079 mem::swap(&mut htlc_updates, &mut self.context.holding_cell_htlc_updates);
3080- let mut update_add_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3081- let mut update_fulfill_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3082- let mut update_fail_htlcs = Vec::with_capacity(htlc_updates.len()) ;
3080+ let mut update_add_count = 0 ;
3081+ let mut update_fulfill_count = 0 ;
3082+ let mut update_fail_count = 0 ;
30833083 let mut htlcs_to_fail = Vec::new();
30843084 for htlc_update in htlc_updates.drain(..) {
30853085 // Note that this *can* fail, though it should be due to rather-rare conditions on
@@ -3095,7 +3095,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30953095 match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
30963096 onion_routing_packet.clone(), false, skimmed_fee_msat, fee_estimator, logger)
30973097 {
3098- Ok(update_add_msg_option ) => update_add_htlcs.push(update_add_msg_option.unwrap()) ,
3098+ Ok(_ ) => update_add_count += 1 ,
30993099 Err(e) => {
31003100 match e {
31013101 ChannelError::Ignore(ref msg) => {
@@ -3122,11 +3122,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31223122 // not fail - any in between attempts to claim the HTLC will have resulted
31233123 // in it hitting the holding cell again and we cannot change the state of a
31243124 // holding cell HTLC from fulfill to anything else.
3125- let (update_fulfill_msg_option, mut additional_monitor_update) =
3126- if let UpdateFulfillFetch::NewClaim { msg, monitor_update, .. } = self.get_update_fulfill_htlc(htlc_id, *payment_preimage, logger) {
3127- (msg, monitor_update )
3128- } else { unreachable!() };
3129- update_fulfill_htlcs.push(update_fulfill_msg_option.unwrap()) ;
3125+ let mut additional_monitor_update =
3126+ if let UpdateFulfillFetch::NewClaim { monitor_update, .. } =
3127+ self.get_update_fulfill_htlc(htlc_id, *payment_preimage, logger )
3128+ { monitor_update } else { unreachable!() };
3129+ update_fulfill_count += 1 ;
31303130 monitor_update.updates.append(&mut additional_monitor_update.updates);
31313131 },
31323132 &HTLCUpdateAwaitingACK::FailHTLC { htlc_id, ref err_packet } => {
@@ -3137,7 +3137,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31373137 // not fail - we should never end up in a state where we double-fail
31383138 // an HTLC or fail-then-claim an HTLC as it indicates we didn't wait
31393139 // for a full revocation before failing.
3140- update_fail_htlcs.push(update_fail_msg_option.unwrap())
3140+ debug_assert!(update_fail_msg_option.is_some());
3141+ update_fail_count += 1;
31413142 },
31423143 Err(e) => {
31433144 if let ChannelError::Ignore(_) = e {}
@@ -3149,7 +3150,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31493150 },
31503151 }
31513152 }
3152- if update_add_htlcs.is_empty() && update_fulfill_htlcs.is_empty() && update_fail_htlcs.is_empty() && self.context.holding_cell_update_fee.is_none() {
3153+ if update_add_count == 0 && update_fulfill_count == 0 && update_fail_count == 0 && self.context.holding_cell_update_fee.is_none() {
31533154 return (None, htlcs_to_fail);
31543155 }
31553156 let update_fee = if let Some(feerate) = self.context.holding_cell_update_fee.take() {
@@ -3166,7 +3167,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31663167
31673168 log_debug!(logger, "Freeing holding cell in channel {} resulted in {}{} HTLCs added, {} HTLCs fulfilled, and {} HTLCs failed.",
31683169 log_bytes!(self.context.channel_id()), if update_fee.is_some() { "a fee update, " } else { "" },
3169- update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len() );
3170+ update_add_count, update_fulfill_count, update_fail_count );
31703171
31713172 self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
31723173 (self.push_ret_blockable_mon_update(monitor_update), htlcs_to_fail)
0 commit comments