Skip to content

Commit bd3cc00

Browse files
authored
Merge pull request #3033 from TheBlueMatt/2024-04-notify-bp-on-blocks
Wake `background-processor` from `ChainMonitor` on new blocks
2 parents b403411 + 021979b commit bd3cc00

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/chain/chainmonitor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ pub struct ChainMonitor<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T:
296296
/// The best block height seen, used as a proxy for the passage of time.
297297
highest_chain_height: AtomicUsize,
298298

299+
/// A [`Notifier`] used to wake up the background processor in case we have any [`Event`]s for
300+
/// it to give to users (or [`MonitorEvent`]s for `ChannelManager` to process).
299301
event_notifier: Notifier,
300302
}
301303

@@ -738,6 +740,8 @@ where
738740
monitor.block_connected(
739741
header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
740742
});
743+
// Assume we may have some new events and wake the event processor
744+
self.event_notifier.notify();
741745
}
742746

743747
fn block_disconnected(&self, header: &Header, height: u32) {
@@ -765,6 +769,8 @@ where
765769
monitor.transactions_confirmed(
766770
header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
767771
});
772+
// Assume we may have some new events and wake the event processor
773+
self.event_notifier.notify();
768774
}
769775

770776
fn transaction_unconfirmed(&self, txid: &Txid) {
@@ -785,6 +791,8 @@ where
785791
header, height, &*self.broadcaster, &*self.fee_estimator, &self.logger
786792
)
787793
});
794+
// Assume we may have some new events and wake the event processor
795+
self.event_notifier.notify();
788796
}
789797

790798
fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option<BlockHash>)> {

0 commit comments

Comments
 (0)