Skip to content

Commit 3d38364

Browse files
Update ChannelManager docs
Updates multiple instances of the `ChannelManager` docs related to the previous change that moved the storage of the channels to the `per_peer_state`. This docs update corrects some grammar errors and incorrect information, as well as clarifies documentation that was confusing.
1 parent b45d69e commit 3d38364

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,8 @@ where
767767
/// very far in the past, and can only ever be up to two hours in the future.
768768
highest_seen_timestamp: AtomicUsize,
769769

770-
/// The bulk of our storage will eventually be here (message queues and the like). Currently
771-
/// the `per_peer_state` stores our channels on a per-peer basis, as well as the peer's latest
772-
/// features.
770+
/// The bulk of our storage. Currently the `per_peer_state` stores our channels on a per-peer
771+
/// basis, as well as the peer's latest features.
773772
///
774773
/// If we are connected to a peer we always at least have an entry here, even if no channels
775774
/// are currently open with that peer.
@@ -1250,7 +1249,7 @@ macro_rules! handle_error {
12501249
#[cfg(any(feature = "_test_utils", test))]
12511250
{
12521251
if per_peer_state.get(&$counterparty_node_id).is_none() {
1253-
// This shouldn't occour in tests unless an unkown counterparty_node_id
1252+
// This shouldn't occur in tests unless an unknown counterparty_node_id
12541253
// has been passed to our message handling functions.
12551254
let expected_error_str = format!("Can't find a peer matching the passed counterparty node_id {}", $counterparty_node_id);
12561255
match err.action {
@@ -2313,7 +2312,9 @@ where
23132312
/// public, and thus should be called whenever the result is going to be passed out in a
23142313
/// [`MessageSendEvent::BroadcastChannelUpdate`] event.
23152314
///
2316-
/// May be called with peer_state already locked!
2315+
/// Note that in `internal_closing_signed`, this function is called without the `peer_state`
2316+
/// corresponding to the channel's counterparty locked, as the channel been removed from the
2317+
/// storage and the `peer_state` lock has been dropped.
23172318
fn get_channel_update_for_broadcast(&self, chan: &Channel<<SP::Target as SignerProvider>::Signer>) -> Result<msgs::ChannelUpdate, LightningError> {
23182319
if !chan.should_announce() {
23192320
return Err(LightningError {
@@ -2332,7 +2333,10 @@ where
23322333
/// is public (only returning an Err if the channel does not yet have an assigned short_id),
23332334
/// and thus MUST NOT be called unless the recipient of the resulting message has already
23342335
/// provided evidence that they know about the existence of the channel.
2335-
/// May be called with peer_state already locked!
2336+
///
2337+
/// Note that through `internal_closing_signed`, this function is called without the
2338+
/// `peer_state` corresponding to the channel's counterparty locked, as the channel been
2339+
/// removed from the storage and the `peer_state` lock has been dropped.
23362340
fn get_channel_update_for_unicast(&self, chan: &Channel<<SP::Target as SignerProvider>::Signer>) -> Result<msgs::ChannelUpdate, LightningError> {
23372341
log_trace!(self.logger, "Attempting to generate channel update for channel {}", log_bytes!(chan.channel_id()));
23382342
let short_channel_id = match chan.get_short_channel_id().or(chan.latest_inbound_scid_alias()) {
@@ -3712,7 +3716,7 @@ where
37123716
fn fail_htlc_backwards_internal(&self, source: &HTLCSource, payment_hash: &PaymentHash, onion_error: &HTLCFailReason, destination: HTLCDestination) {
37133717
#[cfg(any(feature = "_test_utils", test))]
37143718
{
3715-
// Ensure that no peer state channel storage lock is not held when calling this
3719+
// Ensure that the peer state channel storage lock is not held when calling this
37163720
// function.
37173721
// This ensures that future code doesn't introduce a lock_order requirement for
37183722
// `forward_htlcs` to be locked after the `per_peer_state` peer locks, which calling

0 commit comments

Comments
 (0)