X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-block-sync%2Fsrc%2Finit.rs;h=d51cd3ba606f9bd513326cc527ab677459b58b0d;hb=13a33409b519e57b7d14cd9e440223d3495d55eb;hp=59c057157ef14bd6332d0bad1c2207b2919e741c;hpb=793de5fe6944bb6ab414934e53a7ae80bb5a9a31;p=rust-lightning diff --git a/lightning-block-sync/src/init.rs b/lightning-block-sync/src/init.rs index 59c05715..d51cd3ba 100644 --- a/lightning-block-sync/src/init.rs +++ b/lightning-block-sync/src/init.rs @@ -1,3 +1,6 @@ +//! Utilities to assist in the initial sync required to initialize or reload Rust-Lightning objects +//! from disk. + use crate::{BlockSource, BlockSourceResult, Cache, ChainNotifier}; use crate::poll::{ChainPoller, Validate, ValidatedBlockHeader}; @@ -11,6 +14,8 @@ use lightning::chain; /// /// Upon success, the returned header can be used to initialize [`SpvClient`]. Useful during a fresh /// start when there are no chain listeners to sync yet. +/// +/// [`SpvClient`]: crate::SpvClient pub async fn validate_best_block_header(block_source: &mut B) -> BlockSourceResult { let (best_block_hash, best_block_height) = block_source.get_best_block().await?; @@ -73,12 +78,12 @@ BlockSourceResult { /// ) { /// // Read a serialized channel monitor paired with the block hash when it was persisted. /// let serialized_monitor = "..."; -/// let (monitor_block_hash_option, mut monitor) = <(Option, ChannelMonitor)>::read( +/// let (monitor_block_hash, mut monitor) = <(BlockHash, ChannelMonitor)>::read( /// &mut Cursor::new(&serialized_monitor), keys_manager).unwrap(); /// /// // Read the channel manager paired with the block hash when it was persisted. /// let serialized_manager = "..."; -/// let (manager_block_hash_option, mut manager) = { +/// let (manager_block_hash, mut manager) = { /// let read_args = ChannelManagerReadArgs::new( /// keys_manager, /// fee_estimator, @@ -88,20 +93,17 @@ BlockSourceResult { /// config, /// vec![&mut monitor], /// ); -/// <(Option, ChannelManager, &T, &K, &F, &L>)>::read( +/// <(BlockHash, ChannelManager, &T, &K, &F, &L>)>::read( /// &mut Cursor::new(&serialized_manager), read_args).unwrap() /// }; /// /// // Synchronize any channel monitors and the channel manager to be on the best block. /// let mut cache = UnboundedCache::new(); /// let mut monitor_listener = (monitor, &*tx_broadcaster, &*fee_estimator, &*logger); -/// let mut listeners = vec![]; -/// if let Some(monitor_block_hash) = monitor_block_hash_option { -/// listeners.push((monitor_block_hash, &mut monitor_listener as &mut dyn chain::Listen)) -/// } -/// if let Some(manager_block_hash) = manager_block_hash_option { -/// listeners.push((manager_block_hash, &mut manager as &mut dyn chain::Listen)) -/// } +/// let listeners = vec![ +/// (monitor_block_hash, &mut monitor_listener as &mut dyn chain::Listen), +/// (manager_block_hash, &mut manager as &mut dyn chain::Listen), +/// ]; /// let chain_tip = init::synchronize_listeners( /// block_source, Network::Bitcoin, &mut cache, listeners).await.unwrap(); /// @@ -116,9 +118,9 @@ BlockSourceResult { /// } /// ``` /// -/// [`SpvClient`]: ../struct.SpvClient.html -/// [`ChannelManager`]: ../../lightning/ln/channelmanager/struct.ChannelManager.html -/// [`ChannelMonitor`]: ../../lightning/chain/channelmonitor/struct.ChannelMonitor.html +/// [`SpvClient`]: crate::SpvClient +/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager +/// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor pub async fn synchronize_listeners( block_source: &mut B, network: Network,