Skip to content

Commit ea15f0f

Browse files
authored
Merge pull request #2100 from douglaz/docs_fixes
Docs improvements
2 parents 1fdb052 + 963d6c4 commit ea15f0f

File tree

8 files changed

+119
-98
lines changed

8 files changed

+119
-98
lines changed

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ mod tests {
861861
// 0085 3d00000000000000000000000000000000000000000000000000000000000000 0900000000000000000000000000000000000000000000000000000000000000 020b00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000 - revoke_and_ack and mac
862862
//
863863
// 07 - process the now-pending HTLC forward
864-
// - client now sends id 1 update_add_htlc and commitment_signed (CHECK 7: SendHTLCs event for node 03020000 with 1 HTLCs for channel 3f000000)
864+
// - client now sends id 1 update_add_htlc and commitment_signed (CHECK 7: UpdateHTLCs event for node 03020000 with 1 HTLCs for channel 3f000000)
865865
//
866866
// - we respond with commitment_signed then revoke_and_ack (a weird, but valid, order)
867867
// 030112 - inbound read from peer id 1 of len 18

lightning-invoice/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use core::time::Duration;
3838
///
3939
/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
4040
/// in excess of the current time.
41-
///
41+
///
4242
/// `duration_since_epoch` is the current time since epoch in seconds.
4343
///
4444
/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
@@ -56,7 +56,7 @@ use core::time::Duration;
5656
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
5757
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
5858
/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
59-
///
59+
///
6060
/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
6161
/// available and the current time is supplied by the caller.
6262
pub fn create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
@@ -98,7 +98,7 @@ where
9898
///
9999
/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
100100
/// in excess of the current time.
101-
///
101+
///
102102
/// `duration_since_epoch` is the current time since epoch in seconds.
103103
///
104104
/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
@@ -110,7 +110,7 @@ where
110110
/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
111111
/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
112112
/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
113-
///
113+
///
114114
/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
115115
/// available and the current time is supplied by the caller.
116116
pub fn create_phantom_invoice_with_description_hash<ES: Deref, NS: Deref, L: Deref>(

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// licenses.
99

1010
//! Various utilities for building scripts and deriving keys related to channels. These are
11-
//! largely of interest for those implementing chain::keysinterface::Sign message signing by hand.
11+
//! largely of interest for those implementing the traits on [`chain::keysinterface`] by hand.
1212
1313
use bitcoin::blockdata::script::{Script,Builder};
1414
use bitcoin::blockdata::opcodes;

lightning/src/ln/channelmanager.rs

Lines changed: 85 additions & 59 deletions
Large diffs are not rendered by default.

lightning/src/ln/mod.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,7 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
//! High level lightning structs and impls live here.
11-
//!
12-
//! You probably want to create a [`ChannelManager`], and a [`P2PGossipSync`] first.
13-
//! Then, you probably want to pass them both on to a peer_handler::PeerManager and use that to
14-
//! create/manage connections and call get_and_clear_pending_events after each action, handling
15-
//! them appropriately.
16-
//!
17-
//! When you want to open/close a channel or send a payment, call into your [`ChannelManager`] and
18-
//! when you want to learn things about the network topology (eg get a route for sending a payment),
19-
//! call into your [`P2PGossipSync`].
20-
//!
21-
//! [`ChannelManager`]: channelmanager::ChannelManager
22-
//! [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
10+
//! Implementations of various parts of the Lightning protocol are in this module.
2311
2412
#[cfg(any(test, feature = "_test_utils"))]
2513
#[macro_use]

lightning/src/ln/peer_handler.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub struct MessageHandler<CM: Deref, RM: Deref, OM: Deref> where
284284
/// to a remote host. You will need to be able to generate multiple of these which meet Eq and
285285
/// implement Hash to meet the PeerManager API.
286286
///
287-
/// For efficiency, Clone should be relatively cheap for this type.
287+
/// For efficiency, [`Clone`] should be relatively cheap for this type.
288288
///
289289
/// Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original
290290
/// has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it
@@ -547,10 +547,10 @@ pub type SimpleRefPeerManager<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm
547547
/// [`PeerManager`] functions related to the same connection must occur only in serial, making new
548548
/// calls only after previous ones have returned.
549549
///
550-
/// Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
551-
/// a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
552-
/// essentially you should default to using a SimpleRefPeerManager, and use a
553-
/// SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when
550+
/// Rather than using a plain [`PeerManager`], it is preferable to use either a [`SimpleArcPeerManager`]
551+
/// a [`SimpleRefPeerManager`], for conciseness. See their documentation for more details, but
552+
/// essentially you should default to using a [`SimpleRefPeerManager`], and use a
553+
/// [`SimpleArcPeerManager`] when you require a `PeerManager` with a static lifetime, such as when
554554
/// you're using lightning-net-tokio.
555555
///
556556
/// [`read_event`]: PeerManager::read_event
@@ -638,7 +638,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, OM: Deref, L: Deref, NS: Deref> Pe
638638
/// `OnionMessageHandler`. No routing message handler is used and network graph messages are
639639
/// ignored.
640640
///
641-
/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
641+
/// `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be
642642
/// cryptographically secure random bytes.
643643
///
644644
/// `current_time` is used as an always-increasing counter that survives across restarts and is
@@ -670,7 +670,7 @@ impl<Descriptor: SocketDescriptor, RM: Deref, L: Deref, NS: Deref> PeerManager<D
670670
/// timestamp, however if it is not available a persistent counter that increases once per
671671
/// minute should suffice.
672672
///
673-
/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
673+
/// `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be
674674
/// cryptographically secure random bytes.
675675
///
676676
/// (C-not exported) as we can't export a PeerManager with a dummy channel handler
@@ -732,8 +732,9 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
732732
CMH::Target: CustomMessageHandler,
733733
NS::Target: NodeSigner
734734
{
735-
/// Constructs a new PeerManager with the given message handlers and node_id secret key
736-
/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
735+
/// Constructs a new `PeerManager` with the given message handlers.
736+
///
737+
/// `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be
737738
/// cryptographically secure random bytes.
738739
///
739740
/// `current_time` is used as an always-increasing counter that survives across restarts and is
@@ -806,9 +807,9 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
806807
/// Returns a small number of bytes to send to the remote node (currently always 50).
807808
///
808809
/// Panics if descriptor is duplicative with some other descriptor which has not yet been
809-
/// [`socket_disconnected()`].
810+
/// [`socket_disconnected`].
810811
///
811-
/// [`socket_disconnected()`]: PeerManager::socket_disconnected
812+
/// [`socket_disconnected`]: PeerManager::socket_disconnected
812813
pub fn new_outbound_connection(&self, their_node_id: PublicKey, descriptor: Descriptor, remote_network_address: Option<NetAddress>) -> Result<Vec<u8>, PeerHandleError> {
813814
let mut peer_encryptor = PeerChannelEncryptor::new_outbound(their_node_id.clone(), self.get_ephemeral_key());
814815
let res = peer_encryptor.get_act_one(&self.secp_ctx).to_vec();
@@ -863,9 +864,9 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
863864
/// the connection immediately.
864865
///
865866
/// Panics if descriptor is duplicative with some other descriptor which has not yet been
866-
/// [`socket_disconnected()`].
867+
/// [`socket_disconnected`].
867868
///
868-
/// [`socket_disconnected()`]: PeerManager::socket_disconnected
869+
/// [`socket_disconnected`]: PeerManager::socket_disconnected
869870
pub fn new_inbound_connection(&self, descriptor: Descriptor, remote_network_address: Option<NetAddress>) -> Result<(), PeerHandleError> {
870871
let peer_encryptor = PeerChannelEncryptor::new_inbound(&self.node_signer);
871872
let pending_read_buffer = [0; 50].to_vec(); // Noise act one is 50 bytes
@@ -1011,7 +1012,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
10111012
/// May call [`send_data`] on the descriptor passed in (or an equal descriptor) before
10121013
/// returning. Thus, be very careful with reentrancy issues! The invariants around calling
10131014
/// [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be
1014-
/// ready to call `[write_buffer_space_avail`] again if a write call generated here isn't
1015+
/// ready to call [`write_buffer_space_avail`] again if a write call generated here isn't
10151016
/// sufficient!
10161017
///
10171018
/// [`send_data`]: SocketDescriptor::send_data

lightning/src/ln/wire.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(crate) trait TestEq {}
4242
impl<T> TestEq for T {}
4343

4444

45-
/// A Lightning message returned by [`read()`] when decoding bytes received over the wire. Each
45+
/// A Lightning message returned by [`read`] when decoding bytes received over the wire. Each
4646
/// variant contains a message from [`msgs`] or otherwise the message type if unknown.
4747
#[allow(missing_docs)]
4848
#[derive(Debug)]

lightning/src/routing/gossip.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<G: Deref<Target=NetworkGraph<L>>, U: Deref, L: Deref> P2PGossipSync<G, U, L
234234
where U::Target: UtxoLookup, L::Target: Logger
235235
{
236236
/// Creates a new tracker of the actual state of the network of channels and nodes,
237-
/// assuming an existing Network Graph.
237+
/// assuming an existing [`NetworkGraph`].
238238
/// UTXO lookup is used to make sure announced channels exist on-chain, channel data is
239239
/// correct, and the announcement is signed with channel owners' keys.
240240
pub fn new(network_graph: G, utxo_lookup: Option<U>, logger: L) -> Self {
@@ -432,14 +432,20 @@ where U::Target: UtxoLookup, L::Target: Logger
432432
}
433433

434434
/// Initiates a stateless sync of routing gossip information with a peer
435-
/// using gossip_queries. The default strategy used by this implementation
435+
/// using [`gossip_queries`]. The default strategy used by this implementation
436436
/// is to sync the full block range with several peers.
437437
///
438-
/// We should expect one or more reply_channel_range messages in response
439-
/// to our query_channel_range. Each reply will enqueue a query_scid message
438+
/// We should expect one or more [`reply_channel_range`] messages in response
439+
/// to our [`query_channel_range`]. Each reply will enqueue a [`query_scid`] message
440440
/// to request gossip messages for each channel. The sync is considered complete
441-
/// when the final reply_scids_end message is received, though we are not
441+
/// when the final [`reply_scids_end`] message is received, though we are not
442442
/// tracking this directly.
443+
///
444+
/// [`gossip_queries`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#query-messages
445+
/// [`reply_channel_range`]: msgs::ReplyChannelRange
446+
/// [`query_channel_range`]: msgs::QueryChannelRange
447+
/// [`query_scid`]: msgs::QueryShortChannelIds
448+
/// [`reply_scids_end`]: msgs::ReplyShortChannelIdsEnd
443449
fn peer_connected(&self, their_node_id: &PublicKey, init_msg: &Init, _inbound: bool) -> Result<(), ()> {
444450
// We will only perform a sync with peers that support gossip_queries.
445451
if !init_msg.features.supports_gossip_queries() {

0 commit comments

Comments
 (0)