Skip to content

Commit

Permalink
Merge pull request #3033 from TheBlueMatt/2024-04-notify-bp-on-blocks
Browse files Browse the repository at this point in the history
Wake `background-processor` from `ChainMonitor` on new blocks
  • Loading branch information
TheBlueMatt authored May 1, 2024
2 parents b403411 + 021979b commit bd3cc00
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lightning/src/chain/chainmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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>)> {
Expand Down

0 comments on commit bd3cc00

Please sign in to comment.