Skip to content

Commit a15d0b5

Browse files
committed
Docs improvements for channel
1 parent 685f266 commit a15d0b5

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

lightning/src/ln/channel.rs

+26-24
Original file line numberDiff line numberDiff line change
@@ -250,52 +250,52 @@ enum HTLCUpdateAwaitingACK {
250250
}
251251

252252
/// There are a few "states" and then a number of flags which can be applied:
253-
/// We first move through init with OurInitSent -> TheirInitSent -> FundingCreated -> FundingSent.
254-
/// TheirChannelReady and OurChannelReady then get set on FundingSent, and when both are set we
255-
/// move on to ChannelReady.
256-
/// Note that PeerDisconnected can be set on both ChannelReady and FundingSent.
257-
/// ChannelReady can then get all remaining flags set on it, until we finish shutdown, then we
258-
/// move on to ShutdownComplete, at which point most calls into this channel are disallowed.
253+
/// We first move through init with `OurInitSent` -> `TheirInitSent` -> `FundingCreated` -> `FundingSent`.
254+
/// `TheirChannelReady` and `OurChannelReady` then get set on `FundingSent`, and when both are set we
255+
/// move on to `ChannelReady`.
256+
/// Note that `PeerDisconnected` can be set on both `ChannelReady` and `FundingSent`.
257+
/// `ChannelReady` can then get all remaining flags set on it, until we finish shutdown, then we
258+
/// move on to `ShutdownComplete`, at which point most calls into this channel are disallowed.
259259
enum ChannelState {
260260
/// Implies we have (or are prepared to) send our open_channel/accept_channel message
261261
OurInitSent = 1 << 0,
262-
/// Implies we have received their open_channel/accept_channel message
262+
/// Implies we have received their `open_channel`/`accept_channel` message
263263
TheirInitSent = 1 << 1,
264-
/// We have sent funding_created and are awaiting a funding_signed to advance to FundingSent.
265-
/// Note that this is nonsense for an inbound channel as we immediately generate funding_signed
266-
/// upon receipt of funding_created, so simply skip this state.
264+
/// We have sent `funding_created` and are awaiting a `funding_signed` to advance to `FundingSent`.
265+
/// Note that this is nonsense for an inbound channel as we immediately generate `funding_signed`
266+
/// upon receipt of `funding_created`, so simply skip this state.
267267
FundingCreated = 4,
268-
/// Set when we have received/sent funding_created and funding_signed and are thus now waiting
269-
/// on the funding transaction to confirm. The ChannelReady flags are set to indicate when we
268+
/// Set when we have received/sent `funding_created` and `funding_signed` and are thus now waiting
269+
/// on the funding transaction to confirm. The `ChannelReady` flags are set to indicate when we
270270
/// and our counterparty consider the funding transaction confirmed.
271271
FundingSent = 8,
272-
/// Flag which can be set on FundingSent to indicate they sent us a channel_ready message.
273-
/// Once both TheirChannelReady and OurChannelReady are set, state moves on to ChannelReady.
272+
/// Flag which can be set on `FundingSent` to indicate they sent us a `channel_ready` message.
273+
/// Once both `TheirChannelReady` and `OurChannelReady` are set, state moves on to `ChannelReady`.
274274
TheirChannelReady = 1 << 4,
275-
/// Flag which can be set on FundingSent to indicate we sent them a channel_ready message.
276-
/// Once both TheirChannelReady and OurChannelReady are set, state moves on to ChannelReady.
275+
/// Flag which can be set on `FundingSent` to indicate we sent them a `channel_ready` message.
276+
/// Once both `TheirChannelReady` and `OurChannelReady` are set, state moves on to `ChannelReady`.
277277
OurChannelReady = 1 << 5,
278278
ChannelReady = 64,
279-
/// Flag which is set on ChannelReady and FundingSent indicating remote side is considered
280-
/// "disconnected" and no updates are allowed until after we've done a channel_reestablish
279+
/// Flag which is set on `ChannelReady` and `FundingSent` indicating remote side is considered
280+
/// "disconnected" and no updates are allowed until after we've done a `channel_reestablish`
281281
/// dance.
282282
PeerDisconnected = 1 << 7,
283-
/// Flag which is set on ChannelReady, FundingCreated, and FundingSent indicating the user has
284-
/// told us a ChannelMonitor update is pending async persistence somewhere and we should pause
283+
/// Flag which is set on `ChannelReady`, FundingCreated, and `FundingSent` indicating the user has
284+
/// told us a `ChannelMonitor` update is pending async persistence somewhere and we should pause
285285
/// sending any outbound messages until they've managed to finish.
286286
MonitorUpdateInProgress = 1 << 8,
287287
/// Flag which implies that we have sent a commitment_signed but are awaiting the responding
288288
/// revoke_and_ack message. During this time period, we can't generate new commitment_signed
289289
/// messages as then we will be unable to determine which HTLCs they included in their
290290
/// revoke_and_ack implicit ACK, so instead we have to hold them away temporarily to be sent
291291
/// later.
292-
/// Flag is set on ChannelReady.
292+
/// Flag is set on `ChannelReady`.
293293
AwaitingRemoteRevoke = 1 << 9,
294-
/// Flag which is set on ChannelReady or FundingSent after receiving a shutdown message from
294+
/// Flag which is set on `ChannelReady` or `FundingSent` after receiving a shutdown message from
295295
/// the remote end. If set, they may not add any new HTLCs to the channel, and we are expected
296296
/// to respond with our own shutdown message when possible.
297297
RemoteShutdownSent = 1 << 10,
298-
/// Flag which is set on ChannelReady or FundingSent after sending a shutdown message. At this
298+
/// Flag which is set on `ChannelReady` or `FundingSent` after sending a shutdown message. At this
299299
/// point, we may not add any new HTLCs to the channel.
300300
LocalShutdownSent = 1 << 11,
301301
/// We've successfully negotiated a closing_signed dance. At this point ChannelManager is about
@@ -4869,14 +4869,16 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
48694869
// something in the handler for the message that prompted this message):
48704870

48714871
/// Gets an UnsignedChannelAnnouncement for this channel. The channel must be publicly
4872-
/// announceable and available for use (have exchanged ChannelReady messages in both
4872+
/// announceable and available for use (have exchanged [`ChannelReady`] messages in both
48734873
/// directions). Should be used for both broadcasted announcements and in response to an
48744874
/// AnnouncementSignatures message from the remote peer.
48754875
///
48764876
/// Will only fail if we're not in a state where channel_announcement may be sent (including
48774877
/// closing).
48784878
///
48794879
/// This will only return ChannelError::Ignore upon failure.
4880+
///
4881+
/// [`ChannelReady`]: crate::ln::msgs::ChannelReady
48804882
fn get_channel_announcement<NS: Deref>(
48814883
&self, node_signer: &NS, chain_hash: BlockHash, user_config: &UserConfig,
48824884
) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> where NS::Target: NodeSigner {

0 commit comments

Comments
 (0)