From 6a7c471369ea3bde4625da9601873d4f1dca9bd3 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 9 Dec 2019 22:18:41 -0500 Subject: [PATCH] Remove superflous pending_claims As local onchain txn are already monitored in block_connected by check_spend_local_transaction, it's useless to generate twice pending claims for HTLC outputs on local commitment tx. We could do the alternative. --- lightning/src/ln/channelmonitor.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 72e8e210a..2aded100c 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -2383,16 +2383,14 @@ impl ChannelMonitor { } } } - let mut pending_claims = Vec::new(); if let Some(ref cur_local_tx) = self.current_local_signed_commitment_tx { if self.would_broadcast_at_height(height) { log_trace!(self, "Broadcast onchain {}", log_tx!(cur_local_tx.tx)); broadcaster.broadcast_transaction(&cur_local_tx.tx); match self.key_storage { Storage::Local { ref delayed_payment_base_key, ref latest_per_commitment_point, .. } => { - let (txs, mut spendable_output, new_outputs, mut pending_txn) = self.broadcast_by_local_state(&cur_local_tx, latest_per_commitment_point, &Some(*delayed_payment_base_key), height); + let (txs, mut spendable_output, new_outputs, _) = self.broadcast_by_local_state(&cur_local_tx, latest_per_commitment_point, &Some(*delayed_payment_base_key), height); spendable_outputs.append(&mut spendable_output); - pending_claims.append(&mut pending_txn); if !new_outputs.is_empty() { watch_outputs.push((cur_local_tx.txid.clone(), new_outputs)); } @@ -2402,9 +2400,8 @@ impl ChannelMonitor { } }, Storage::Watchtower { .. } => { - let (txs, mut spendable_output, new_outputs, mut pending_txn) = self.broadcast_by_local_state(&cur_local_tx, &None, &None, height); + let (txs, mut spendable_output, new_outputs, _) = self.broadcast_by_local_state(&cur_local_tx, &None, &None, height); spendable_outputs.append(&mut spendable_output); - pending_claims.append(&mut pending_txn); if !new_outputs.is_empty() { watch_outputs.push((cur_local_tx.txid.clone(), new_outputs)); } @@ -2416,12 +2413,6 @@ impl ChannelMonitor { } } } - for claim in pending_claims { - match self.pending_claim_requests.entry(claim.0) { - hash_map::Entry::Occupied(_) => {}, - hash_map::Entry::Vacant(entry) => { entry.insert(claim.1); } - } - } if let Some(events) = self.onchain_events_waiting_threshold_conf.remove(&height) { for ev in events { match ev { -- 2.39.5