]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove superflous pending_claims
authorAntoine Riard <ariard@student.42.fr>
Tue, 10 Dec 2019 03:18:41 +0000 (22:18 -0500)
committerMatt Corallo <git@bluematt.me>
Tue, 10 Dec 2019 03:22:52 +0000 (22:22 -0500)
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

index 72e8e210a31f23879c40ecfe9e132ada2df433c7..2aded100c149e6dd27a93afbb5d0e0c8ed621132 100644 (file)
@@ -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 {