Skip to content

Commit 2fab887

Browse files
committed
Correct lightning-net-tokio documentation, remove stale example
The `lightning-net-tokio` crate-level example contained a carryover from when it was the primary notifier of the background processor and now just shows an "example" of creating a method to call another method with the same parameters and then do event processing (which doesn't make sense, the BP should do that). Instead, the examples are simply removed and the documentation is tweaked to include recent changes.
1 parent 0e28bcb commit 2fab887

File tree

1 file changed

+8
-53
lines changed

1 file changed

+8
-53
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,19 @@
88
// licenses.
99

1010
//! A socket handling library for those running in Tokio environments who wish to use
11-
//! rust-lightning with native TcpStreams.
11+
//! rust-lightning with native [`TcpStream`]s.
1212
//!
1313
//! Designed to be as simple as possible, the high-level usage is almost as simple as "hand over a
14-
//! TcpStream and a reference to a PeerManager and the rest is handled", except for the
15-
//! [Event](../lightning/util/events/enum.Event.html) handling mechanism; see example below.
14+
//! [`TcpStream`] and a reference to a [`PeerManager`] and the rest is handled".
1615
//!
17-
//! The PeerHandler, due to the fire-and-forget nature of this logic, must be an Arc, and must use
18-
//! the SocketDescriptor provided here as the PeerHandler's SocketDescriptor.
16+
//! The [`PeerManager`], due to the fire-and-forget nature of this logic, must be a reference,
17+
//! (e.g. an [`Arc`]) and must use the [`SocketDescriptor`] provided here as the [`PeerManager`]'s
18+
//! `SocketDescriptor` implementation.
1919
//!
20-
//! Three methods are exposed to register a new connection for handling in tokio::spawn calls; see
21-
//! their individual docs for details.
20+
//! Three methods are exposed to register a new connection for handling in [`tokio::spawn`] calls;
21+
//! see their individual docs for details.
2222
//!
23-
//! # Example
24-
//! ```
25-
//! use std::net::TcpStream;
26-
//! use bitcoin::secp256k1::PublicKey;
27-
//! use lightning::events::{Event, EventHandler, EventsProvider};
28-
//! use std::net::SocketAddr;
29-
//! use std::sync::Arc;
30-
//!
31-
//! // Define concrete types for our high-level objects:
32-
//! type TxBroadcaster = dyn lightning::chain::chaininterface::BroadcasterInterface + Send + Sync;
33-
//! type FeeEstimator = dyn lightning::chain::chaininterface::FeeEstimator + Send + Sync;
34-
//! type Logger = dyn lightning::util::logger::Logger + Send + Sync;
35-
//! type NodeSigner = dyn lightning::chain::keysinterface::NodeSigner + Send + Sync;
36-
//! type UtxoLookup = dyn lightning::routing::utxo::UtxoLookup + Send + Sync;
37-
//! type ChainFilter = dyn lightning::chain::Filter + Send + Sync;
38-
//! type DataPersister = dyn lightning::chain::chainmonitor::Persist<lightning::chain::keysinterface::InMemorySigner> + Send + Sync;
39-
//! type ChainMonitor = lightning::chain::chainmonitor::ChainMonitor<lightning::chain::keysinterface::InMemorySigner, Arc<ChainFilter>, Arc<TxBroadcaster>, Arc<FeeEstimator>, Arc<Logger>, Arc<DataPersister>>;
40-
//! type ChannelManager = Arc<lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor, TxBroadcaster, FeeEstimator, Logger>>;
41-
//! type PeerManager = Arc<lightning::ln::peer_handler::SimpleArcPeerManager<lightning_net_tokio::SocketDescriptor, ChainMonitor, TxBroadcaster, FeeEstimator, UtxoLookup, Logger>>;
42-
//!
43-
//! // Connect to node with pubkey their_node_id at addr:
44-
//! async fn connect_to_node(peer_manager: PeerManager, chain_monitor: Arc<ChainMonitor>, channel_manager: ChannelManager, their_node_id: PublicKey, addr: SocketAddr) {
45-
//! lightning_net_tokio::connect_outbound(peer_manager, their_node_id, addr).await;
46-
//! loop {
47-
//! let event_handler = |event: Event| {
48-
//! // Handle the event!
49-
//! };
50-
//! channel_manager.await_persistable_update();
51-
//! channel_manager.process_pending_events(&event_handler);
52-
//! chain_monitor.process_pending_events(&event_handler);
53-
//! }
54-
//! }
55-
//!
56-
//! // Begin reading from a newly accepted socket and talk to the peer:
57-
//! async fn accept_socket(peer_manager: PeerManager, chain_monitor: Arc<ChainMonitor>, channel_manager: ChannelManager, socket: TcpStream) {
58-
//! lightning_net_tokio::setup_inbound(peer_manager, socket);
59-
//! loop {
60-
//! let event_handler = |event: Event| {
61-
//! // Handle the event!
62-
//! };
63-
//! channel_manager.await_persistable_update();
64-
//! channel_manager.process_pending_events(&event_handler);
65-
//! chain_monitor.process_pending_events(&event_handler);
66-
//! }
67-
//! }
68-
//! ```
23+
//! [`PeerManager`]: lightning::ln::peer_handler::PeerManager
6924
7025
// Prefix these with `rustdoc::` when we update our MSRV to be >= 1.52 to remove warnings.
7126
#![deny(broken_intra_doc_links)]

0 commit comments

Comments
 (0)