Skip to content

Commit eeb721d

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 36834b3 commit eeb721d

File tree

1 file changed

+3
-51
lines changed

1 file changed

+3
-51
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,13 @@
1111
//! rust-lightning with native TcpStreams.
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 PeerHandler, due to the fire-and-forget nature of this logic, must be a reference, (e.g. an
17+
//! `Arc`) and must use the SocketDescriptor provided here as the PeerHandler's SocketDescriptor.
1918
//!
2019
//! Three methods are exposed to register a new connection for handling in tokio::spawn calls; see
2120
//! their individual docs for details.
22-
//!
23-
//! # Example
24-
//! ```
25-
//! use std::net::TcpStream;
26-
//! use bitcoin::secp256k1::PublicKey;
27-
//! use lightning::util::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-
//! ```
6921
7022
// Prefix these with `rustdoc::` when we update our MSRV to be >= 1.52 to remove warnings.
7123
#![deny(broken_intra_doc_links)]

0 commit comments

Comments
 (0)