Separate ChannelManager needing persistence from having events
authorMatt Corallo <git@bluematt.me>
Fri, 8 Sep 2023 20:26:29 +0000 (20:26 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 12 Sep 2023 19:06:34 +0000 (19:06 +0000)
commit7fa499c188294cf4179e57cc47050e9a261ed72b
tree2f04417cf331ebe0c6ebae8d475a2ff59f8a39ad
parent63e6b80fb034b56d4fc0b7b1f3d3ce317ffecfe0
Separate ChannelManager needing persistence from having events

Currently, when a ChannelManager generates a notification for the
background processor, any pending events are handled and the
ChannelManager is always re-persisted.

Many channel related messages don't actually change the channel
state in a way that changes the persisted channel. For example,
an `update_add_htlc` or `update_fail_htlc` message simply adds the
change to a queue, changing the channel state when we receive a
`commitment_signed` message.

In these cases we shouldn't be re-persisting the ChannelManager as
it hasn't changed (persisted) state at all. In anticipation of
doing so in the next few commits, here we make the public API
handle the two concepts (somewhat) separately. The notification
still goes out via a single waker, however whether or not to
persist is now handled via a separate atomic bool.
lightning-background-processor/src/lib.rs
lightning/src/ln/channelmanager.rs