]> git.bitcoin.ninja Git - rust-lightning/commit
Make it harder to forget to call CM::process_background_events
authorMatt Corallo <git@bluematt.me>
Mon, 11 Sep 2023 03:38:14 +0000 (03:38 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 12 Sep 2023 19:06:34 +0000 (19:06 +0000)
commit63e6b80fb034b56d4fc0b7b1f3d3ce317ffecfe0
tree9ea06f83a0e98e00b23aab208f216f3a6bd92ef7
parentc2aee577701e85495516b45c4f6dfc2f8f4b0e24
Make it harder to forget to call CM::process_background_events

Prior to any actions which may generate a `ChannelMonitorUpdate`,
and in general after startup,
`ChannelManager::process_background_events` must be called. This is
mostly accomplished by doing so on taking the
`total_consistency_lock` via the `PersistenceNotifierGuard`. In
order to skip this call in block connection logic, the
`PersistenceNotifierGuard::optionally_notify` constructor did not
call the `process_background_events` method.

However, this is very easy to misuse - `optionally_notify` does not
convey to the reader that they need to call
`process_background_events` at all.

Here we fix this by adding a separate
`optionally_notify_skipping_background_events` method, making the
requirements much clearer to callers.
lightning/src/ln/channelmanager.rs