Merge pull request #3033 from TheBlueMatt/2024-04-notify-bp-on-blocks
[rust-lightning] / lightning / src / chain / chainmonitor.rs
index 81ba30ffb83ed964ca4fe13901be979073e2e6ad..8e567087054b4a0b11e5bc495cc074343e398b6f 100644 (file)
@@ -296,6 +296,8 @@ pub struct ChainMonitor<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T:
        /// The best block height seen, used as a proxy for the passage of time.
        highest_chain_height: AtomicUsize,
 
+       /// A [`Notifier`] used to wake up the background processor in case we have any [`Event`]s for
+       /// it to give to users (or [`MonitorEvent`]s for `ChannelManager` to process).
        event_notifier: Notifier,
 }
 
@@ -738,6 +740,8 @@ where
                        monitor.block_connected(
                                header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
                });
+               // Assume we may have some new events and wake the event processor
+               self.event_notifier.notify();
        }
 
        fn block_disconnected(&self, header: &Header, height: u32) {
@@ -765,6 +769,8 @@ where
                        monitor.transactions_confirmed(
                                header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
                });
+               // Assume we may have some new events and wake the event processor
+               self.event_notifier.notify();
        }
 
        fn transaction_unconfirmed(&self, txid: &Txid) {
@@ -785,6 +791,8 @@ where
                                header, height, &*self.broadcaster, &*self.fee_estimator, &self.logger
                        )
                });
+               // Assume we may have some new events and wake the event processor
+               self.event_notifier.notify();
        }
 
        fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option<BlockHash>)> {