Skip to content

Commit 0ed242e

Browse files
committed
f - Document the example code
1 parent c218b02 commit 0ed242e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: lightning-block-sync/src/init.rs

+5
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ use lightning::chain;
6060
/// logger: &L,
6161
/// persister: &P,
6262
/// ) {
63+
/// // Read a serialized channel monitor paired with the block hash when it was persisted.
6364
/// let serialized_monitor = "...";
6465
/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor<S>)>::read(
6566
/// &mut Cursor::new(&serialized_monitor), keys_manager).unwrap();
6667
///
68+
/// // Read the channel manager paired with the block hash when it was persisted.
6769
/// let serialized_manager = "...";
6870
/// let (manager_block_hash, mut manager) = {
6971
/// let read_args = ChannelManagerReadArgs::new(
@@ -79,6 +81,7 @@ use lightning::chain;
7981
/// &mut Cursor::new(&serialized_manager), read_args).unwrap()
8082
/// };
8183
///
84+
/// // Synchronize any channel monitors and the channel manager to be on the best block.
8285
/// let mut cache = UnboundedCache::new();
8386
/// let mut monitor_listener = (RefCell::new(monitor), &*tx_broadcaster, &*fee_estimator, &*logger);
8487
/// let listeners = vec![
@@ -88,9 +91,11 @@ use lightning::chain;
8891
/// let chain_tip = init::synchronize_listeners(
8992
/// block_source, Network::Bitcoin, &mut cache, listeners).await.unwrap();
9093
///
94+
/// // Allow the chain monitor to watch any channels.
9195
/// let monitor = monitor_listener.0.into_inner();
9296
/// chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
9397
///
98+
/// // Create an SPV client to notify the chain monitor and channel manager of block events.
9499
/// let chain_poller = poll::ChainPoller::new(block_source, Network::Bitcoin);
95100
/// let mut chain_listener = (chain_monitor, &manager);
96101
/// let spv_client = SpvClient::new(chain_tip, chain_poller, &mut cache, &chain_listener);

0 commit comments

Comments
 (0)