Lean on the holding cell when batch-forwarding/failing HTLCs
authorMatt Corallo <git@bluematt.me>
Sat, 19 Nov 2022 00:00:28 +0000 (00:00 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 6 Dec 2022 18:18:26 +0000 (18:18 +0000)
commitcae7c8180b2e0c994bbc28ed514abccb90a4018e
treef1a6072e14018c227d2acf68e68284456ac5ec15
parent52edb351575ec997c414a66df0142f46a39aeba3
Lean on the holding cell when batch-forwarding/failing HTLCs

When we batch HTLC updates, we currently do the explicit queueing
plus the commitment generation in the `ChannelManager`. This is a
bit strange as its ultimately really a `Channel` responsibility to
generate commitments at the correct time, with the abstraction
leaking into `ChannelManager` with the `send_htlc` and
`get_update_fail_htlc` method docs having clear comments about
how `send_commitment` MUST be called prior to calling other
`Channel` methods.

Luckily `Channel` already has an update queue - the holding cell.
Thus, we can trivially rewrite the batch update logic as inserting
the desired updates into the holding cell and then asking all
channels to clear their holding cells.
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs