Skip to content

Commit 0348de2

Browse files
committed
Wake background-processor from ChainMonitor on new blocks
When we receive a new block we may generate `Event::SpendableOutputs` in `ChannelMonitor`s which then need to be processed by the background processor. While it will do so eventually when its normal loop goes around, this may cause user tests to be delayed in finding events, so we should notify the BP immediately to wake it on new blocks. We implement that here, unconditionally notifying the `background-processor` whenever we receive a new block or confirmed transactions.
1 parent 2b14cc4 commit 0348de2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning/src/chain/chainmonitor.rs

+6
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ where
738738
monitor.block_connected(
739739
header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
740740
});
741+
// Assume we may have some new events and wake the event processor
742+
self.event_notifier.notify();
741743
}
742744

743745
fn block_disconnected(&self, header: &Header, height: u32) {
@@ -765,6 +767,8 @@ where
765767
monitor.transactions_confirmed(
766768
header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger)
767769
});
770+
// Assume we may have some new events and wake the event processor
771+
self.event_notifier.notify();
768772
}
769773

770774
fn transaction_unconfirmed(&self, txid: &Txid) {
@@ -785,6 +789,8 @@ where
785789
header, height, &*self.broadcaster, &*self.fee_estimator, &self.logger
786790
)
787791
});
792+
// Assume we may have some new events and wake the event processor
793+
self.event_notifier.notify();
788794
}
789795

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

0 commit comments

Comments
 (0)