Skip to content

Commit da396f4

Browse files
f - Fix ChannelManager lock order documentation
1 parent 2192da1 commit da396f4

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
@@ -723,6 +723,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
723723
/// after reloading from disk while replaying blocks against ChannelMonitors.
724724
///
725725
/// See `PendingOutboundPayment` documentation for more info.
726+
///
727+
/// See `ChannelManager` struct-level documentation for lock order requirements.
726728
pending_outbound_payments: Mutex<HashMap<PaymentId, PendingOutboundPayment>>,
727729

728730
/// SCID/SCID Alias -> forward infos. Key of 0 means payments received.
@@ -733,6 +735,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
733735
///
734736
/// Note that no consistency guarantees are made about the existence of a channel with the
735737
/// `short_channel_id` here, nor the `short_channel_id` in the `PendingHTLCInfo`!
738+
///
739+
/// See `ChannelManager` struct-level documentation for lock order requirements.
736740
#[cfg(test)]
737741
pub(super) forward_htlcs: Mutex<HashMap<u64, Vec<HTLCForwardInfo>>>,
738742
#[cfg(not(test))]
@@ -761,6 +765,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
761765
/// We should add `counterparty_node_id`s to `MonitorEvent`s, and eventually rely on it in the
762766
/// future. That would make this map redundant, as only the `ChannelManager::per_peer_state` is
763767
/// required to access the channel with the `counterparty_node_id`.
768+
///
769+
/// See `ChannelManager` struct-level documentation for lock order requirements.
764770
id_to_peer: Mutex<HashMap<[u8; 32], PublicKey>>,
765771

766772
our_network_key: SecretKey,
@@ -795,10 +801,13 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
795801
/// Because adding or removing an entry is rare, we usually take an outer read lock and then
796802
/// operate on the inner value freely. Sadly, this prevents parallel operation when opening a
797803
/// new channel.
804+
///
805+
/// See `ChannelManager` struct-level documentation for lock order requirements.
798806
per_peer_state: RwLock<HashMap<PublicKey, Mutex<PeerState>>>,
799807

808+
/// See `ChannelManager` struct-level documentation for lock order requirements.
800809
pending_events: Mutex<Vec<events::Event>>,
801-
810+
/// See `ChannelManager` struct-level documentation for lock order requirements.
802811
pending_background_events: Mutex<Vec<BackgroundEvent>>,
803812
/// Used when we have to take a BIG lock to make sure everything is self-consistent.
804813
/// Essentially just when we're serializing ourselves out.

0 commit comments

Comments
 (0)