Skip to content

Commit c45d6a0

Browse files
committed
f Document new locking requirements on claimable payments
1 parent 77172ee commit c45d6a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,20 @@ pub struct ChannelManager<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
805805
/// Note that, no consistency guarantees are made about the channels given here actually
806806
/// existing anymore by the time you go to read them!
807807
///
808+
/// When adding to the map, [`pending_claimed_payments`] must also be checked (under the same
809+
/// lock) to ensure we don't get a duplicate payment.
810+
///
808811
/// See `ChannelManager` struct-level documentation for lock order requirements.
809812
claimable_htlcs: Mutex<HashMap<PaymentHash, (events::PaymentPurpose, Vec<ClaimableHTLC>)>>,
810813

811814
/// Map from payment hash to the payment data for HTLCs which we have begun claiming, but which
812815
/// are waiting on a [`ChannelMonitorUpdate`] to complete in order to be surfaced to the user
813816
/// as an [`events::Event::PaymentClaimed`].
814817
///
818+
/// When adding to this map (by moving an entry from [`claimable_htlcs`]), the
819+
/// [`claimable_htlcs`] lock should also be held to ensure we don't end up with a duplicate
820+
/// payment by racing a [`claimable_htlcs`] addition.
821+
///
815822
/// See `ChannelManager` struct-level documentation for lock order requirements.
816823
pending_claimed_payments: Mutex<HashMap<PaymentHash, PendingClaimingPayment>>,
817824

0 commit comments

Comments
 (0)