Skip to content

Commit 9768cad

Browse files
f - Fix ChannelManager lock order documentation
1 parent 367aa84 commit 9768cad

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
721721
/// after reloading from disk while replaying blocks against ChannelMonitors.
722722
///
723723
/// See `PendingOutboundPayment` documentation for more info.
724+
///
725+
/// See `ChannelManager` struct-level documentation for lock order requirements.
724726
pending_outbound_payments: Mutex<HashMap<PaymentId, PendingOutboundPayment>>,
725727

726728
/// SCID/SCID Alias -> forward infos. Key of 0 means payments received.
@@ -731,6 +733,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
731733
///
732734
/// Note that no consistency guarantees are made about the existence of a channel with the
733735
/// `short_channel_id` here, nor the `short_channel_id` in the `PendingHTLCInfo`!
736+
///
737+
/// See `ChannelManager` struct-level documentation for lock order requirements.
734738
#[cfg(test)]
735739
pub(super) forward_htlcs: Mutex<HashMap<u64, Vec<HTLCForwardInfo>>>,
736740
#[cfg(not(test))]
@@ -759,6 +763,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
759763
/// We should add `counterparty_node_id`s to `MonitorEvent`s, and eventually rely on it in the
760764
/// future. That would make this map redundant, as only the `ChannelManager::per_peer_state` is
761765
/// required to access the channel with the `counterparty_node_id`.
766+
///
767+
/// See `ChannelManager` struct-level documentation for lock order requirements.
762768
id_to_peer: Mutex<HashMap<[u8; 32], PublicKey>>,
763769

764770
our_network_key: SecretKey,
@@ -789,10 +795,13 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
789795
/// Because adding or removing an entry is rare, we usually take an outer read lock and then
790796
/// operate on the inner value freely. Sadly, this prevents parallel operation when opening a
791797
/// new channel.
798+
///
799+
/// See `ChannelManager` struct-level documentation for lock order requirements.
792800
per_peer_state: RwLock<HashMap<PublicKey, Mutex<PeerState>>>,
793801

802+
/// See `ChannelManager` struct-level documentation for lock order requirements.
794803
pending_events: Mutex<Vec<events::Event>>,
795-
804+
/// See `ChannelManager` struct-level documentation for lock order requirements.
796805
pending_background_events: Mutex<Vec<BackgroundEvent>>,
797806
/// Used when we have to take a BIG lock to make sure everything is self-consistent.
798807
/// Essentially just when we're serializing ourselves out.

0 commit comments

Comments
 (0)