Don't hold `channel_state` lock for entire duration of claim_funds
authorMatt Corallo <git@bluematt.me>
Wed, 30 Nov 2022 05:47:16 +0000 (05:47 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 8 Dec 2022 21:24:26 +0000 (21:24 +0000)
commitdef193d6bda4c46efddd13847612ceb58d040dc1
treeefc912fc254150d18f277daca18ef320e53788b4
parent7b77a016b58face4a2d8a97edae84f2777094ee3
Don't hold `channel_state` lock for entire duration of claim_funds

When `claim_funds` has to claim multiple HTLCs as a part of a
single MPP payment, it currently does so holding the
`channel_state` lock for the entire duration of the claim loop.
Here we swap that for taking the lock once for each HTLC. This
allows us to be more flexible with locks going forward, and
ultimately isn't a huge change - if our counterparty intends to
force-close a channel, us choosing to ignore it by holding the
`channel_state` lock for the duration of the claim isn't going to
result in a commitment update, it will just result in the preimage
already being in the `ChannelMonitor`.
lightning/src/ln/channelmanager.rs