@@ -225,6 +225,7 @@ impl<I, D> SyncRequestBuilder<I, D> {
225225/// [`chain_tip`](SyncRequestBuilder::chain_tip) (if provided).
226226///
227227/// ```rust
228+ /// # use std::io::{self, Write};
228229/// # use bdk_chain::{bitcoin::{hashes::Hash, ScriptBuf}, local_chain::LocalChain};
229230/// # use bdk_chain::spk_client::SyncRequest;
230231/// # let (local_chain, _) = LocalChain::from_genesis(Hash::all_zeros());
@@ -236,7 +237,22 @@ impl<I, D> SyncRequestBuilder<I, D> {
236237/// // Provide list of scripts to scan for transactions against.
237238/// .spks(scripts)
238239/// // This is called for every synced item.
239- /// .inspect(|item, progress| println!("{} (remaining: {})", item, progress.remaining()))
240+ /// .inspect(|item, progress| {
241+ /// let pc = (100.0 * progress.consumed() as f32) / progress.total() as f32;
242+ /// match item {
243+ /// // In this example I = (), so the first field of Spk is unit.
244+ /// bdk_chain::spk_client::SyncItem::Spk((), spk) => {
245+ /// eprintln!("[ SCANNING {pc:03.0}% ] script {}", spk);
246+ /// }
247+ /// bdk_chain::spk_client::SyncItem::Txid(txid) => {
248+ /// eprintln!("[ SCANNING {pc:03.0}% ] txid {}", txid);
249+ /// }
250+ /// bdk_chain::spk_client::SyncItem::OutPoint(op) => {
251+ /// eprintln!("[ SCANNING {pc:03.0}% ] outpoint {}", op);
252+ /// }
253+ /// }
254+ /// let _ = io::stderr().flush();
255+ /// })
240256/// // Finish constructing the sync request.
241257/// .build();
242258/// ```
0 commit comments