@@ -17116,28 +17116,32 @@ fn dedup_decode_update_add_htlcs<L: Deref>(
1711617116) where
1711717117 L::Target: Logger,
1711817118{
17119- decode_update_add_htlcs.retain(|src_outb_alias, update_add_htlcs| {
17120- update_add_htlcs.retain(|update_add| {
17121- let matches = *src_outb_alias == prev_hop_data.prev_outbound_scid_alias
17122- && update_add.htlc_id == prev_hop_data.htlc_id;
17123- if matches {
17124- let logger = WithContext::from(
17125- logger,
17126- prev_hop_data.counterparty_node_id,
17127- Some(update_add.channel_id),
17128- Some(update_add.payment_hash),
17129- );
17130- log_info!(
17131- logger,
17132- "Removing pending to-decode HTLC with id {}: {}",
17133- update_add.htlc_id,
17134- removal_reason
17135- );
17119+ match decode_update_add_htlcs.entry(prev_hop_data.prev_outbound_scid_alias) {
17120+ hash_map::Entry::Occupied(mut update_add_htlcs) => {
17121+ update_add_htlcs.get_mut().retain(|update_add| {
17122+ let matches = update_add.htlc_id == prev_hop_data.htlc_id;
17123+ if matches {
17124+ let logger = WithContext::from(
17125+ logger,
17126+ prev_hop_data.counterparty_node_id,
17127+ Some(update_add.channel_id),
17128+ Some(update_add.payment_hash),
17129+ );
17130+ log_info!(
17131+ logger,
17132+ "Removing pending to-decode HTLC with id {}: {}",
17133+ update_add.htlc_id,
17134+ removal_reason
17135+ );
17136+ }
17137+ !matches
17138+ });
17139+ if update_add_htlcs.get().is_empty() {
17140+ update_add_htlcs.remove();
1713617141 }
17137- !matches
17138- });
17139- !update_add_htlcs.is_empty()
17140- });
17142+ },
17143+ _ => {},
17144+ }
1714117145}
1714217146
1714317147// Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the
0 commit comments