pub struct SyncRequest<I = ()> { /* private fields */ }Expand description
Data required to perform a spk-based blockchain client sync.
A client sync fetches relevant chain data for a known list of scripts, transaction ids and
outpoints. The sync process also updates the chain from the given
chain_tip (if provided).
// Construct a sync request.
let sync_request = SyncRequest::builder()
// Provide chain tip of the local wallet.
.chain_tip(local_chain.tip())
// Provide list of scripts to scan for transactions against.
.spks(scripts)
// This is called for every synced item.
.inspect(|item, progress| println!("{} (remaining: {})", item, progress.remaining()))
// Finish constructing the sync request.
.build();Implementations§
Source§impl<I> SyncRequest<I>
impl<I> SyncRequest<I>
Sourcepub fn builder() -> SyncRequestBuilder<I>
pub fn builder() -> SyncRequestBuilder<I>
Start building a SyncRequest.
Sourcepub fn progress(&self) -> SyncProgress
pub fn progress(&self) -> SyncProgress
Get the SyncProgress of this request.
Sourcepub fn chain_tip(&self) -> Option<CheckPoint>
pub fn chain_tip(&self) -> Option<CheckPoint>
Get the chain tip CheckPoint of this request (if any).
Sourcepub fn next_spk(&mut self) -> Option<ScriptBuf>
pub fn next_spk(&mut self) -> Option<ScriptBuf>
Advances the sync request and returns the next [ScriptBuf].
Returns None when there are no more scripts remaining in the request.
Sourcepub fn next_txid(&mut self) -> Option<Txid>
pub fn next_txid(&mut self) -> Option<Txid>
Advances the sync request and returns the next [Txid].
Returns None when there are no more txids remaining in the request.
Sourcepub fn next_outpoint(&mut self) -> Option<OutPoint>
pub fn next_outpoint(&mut self) -> Option<OutPoint>
Advances the sync request and returns the next [OutPoint].
Returns None when there are no more outpoints in the request.
Sourcepub fn iter_spks(&mut self) -> impl ExactSizeIterator<Item = ScriptBuf> + '_
pub fn iter_spks(&mut self) -> impl ExactSizeIterator<Item = ScriptBuf> + '_
Iterate over [ScriptBuf]s contained in this request.
Sourcepub fn iter_txids(&mut self) -> impl ExactSizeIterator<Item = Txid> + '_
pub fn iter_txids(&mut self) -> impl ExactSizeIterator<Item = Txid> + '_
Iterate over [Txid]s contained in this request.
Sourcepub fn iter_outpoints(&mut self) -> impl ExactSizeIterator<Item = OutPoint> + '_
pub fn iter_outpoints(&mut self) -> impl ExactSizeIterator<Item = OutPoint> + '_
Iterate over [OutPoint]s contained in this request.