Avoid calling OnchainTx::block_disconnected if no block was discon'd
authorMatt Corallo <git@bluematt.me>
Fri, 25 Jun 2021 04:14:50 +0000 (04:14 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 2 Jul 2021 17:16:12 +0000 (17:16 +0000)
There are no visible effects of this, but it seems like good code
hygiene to not call a disconnect function in a different file if no
disconnect happened.

lightning/src/chain/channelmonitor.rs

index 009281958bfd4a1d12fb19ea236497f66c8f7562..d1e6e8114e720816416da16e36064d153c569c7b 100644 (file)
@@ -1927,12 +1927,12 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
                if height > self.best_block.height() {
                        self.best_block = BestBlock::new(block_hash, height);
                        self.block_confirmed(height, vec![], vec![], vec![], broadcaster, fee_estimator, logger)
-               } else {
+               } else if block_hash != self.best_block.block_hash() {
                        self.best_block = BestBlock::new(block_hash, height);
                        self.onchain_events_awaiting_threshold_conf.retain(|ref entry| entry.height <= height);
                        self.onchain_tx_handler.block_disconnected(height + 1, broadcaster, fee_estimator, logger);
                        Vec::new()
-               }
+               } else { Vec::new() }
        }
 
        fn transactions_confirmed<B: Deref, F: Deref, L: Deref>(