pub struct SyncRequestBuilder<I = ()> { /* private fields */ }
Expand description
Builds a SyncRequest
.
Implementations§
Source§impl SyncRequestBuilder<()>
impl SyncRequestBuilder<()>
Sourcepub fn spks(self, spks: impl IntoIterator<Item = ScriptBuf>) -> Self
pub fn spks(self, spks: impl IntoIterator<Item = ScriptBuf>) -> Self
Add [Script
]s that will be synced against.
Source§impl<I> SyncRequestBuilder<I>
impl<I> SyncRequestBuilder<I>
Sourcepub fn chain_tip(self, cp: CheckPoint) -> Self
pub fn chain_tip(self, cp: CheckPoint) -> Self
Set the initial chain tip for the sync request.
This is used to update LocalChain
.
Sourcepub fn spks_with_indexes(
self,
spks: impl IntoIterator<Item = (I, ScriptBuf)>,
) -> Self
pub fn spks_with_indexes( self, spks: impl IntoIterator<Item = (I, ScriptBuf)>, ) -> Self
Add [Script
]s coupled with associated indexes that will be synced against.
§Example
Sync revealed script pubkeys obtained from a
KeychainTxOutIndex
.
let mut indexer = KeychainTxOutIndex::<&'static str>::default();
indexer.insert_descriptor("descriptor_a", descriptor_a)?;
indexer.insert_descriptor("descriptor_b", descriptor_b)?;
/* Assume that the caller does more mutations to the `indexer` here... */
// Reveal spks for "descriptor_a", then build a sync request. Each spk will be indexed with
// `u32`, which represents the derivation index of the associated spk from "descriptor_a".
let (newly_revealed_spks, _changeset) = indexer
.reveal_to_target("descriptor_a", 21)
.expect("keychain must exist");
let _request = SyncRequest::builder()
.spks_with_indexes(newly_revealed_spks)
.build();
// Sync all revealed spks in the indexer. This time, spks may be derived from different
// keychains. Each spk will be indexed with `(&'static str, u32)` where `&'static str` is
// the keychain identifier and `u32` is the derivation index.
let all_revealed_spks = indexer.revealed_spks(..);
let _request = SyncRequest::builder()
.spks_with_indexes(all_revealed_spks)
.build();
Sourcepub fn txids(self, txids: impl IntoIterator<Item = Txid>) -> Self
pub fn txids(self, txids: impl IntoIterator<Item = Txid>) -> Self
Add [Txid
]s that will be synced against.
Sourcepub fn outpoints(self, outpoints: impl IntoIterator<Item = OutPoint>) -> Self
pub fn outpoints(self, outpoints: impl IntoIterator<Item = OutPoint>) -> Self
Add [OutPoint
]s that will be synced against.
Sourcepub fn inspect<F>(self, inspect: F) -> Self
pub fn inspect<F>(self, inspect: F) -> Self
Set the closure that will inspect every sync item visited.
Sourcepub fn build(self) -> SyncRequest<I>
pub fn build(self) -> SyncRequest<I>
Build the SyncRequest
.
Trait Implementations§
Source§impl<I> Default for SyncRequestBuilder<I>
impl<I> Default for SyncRequestBuilder<I>
Source§impl<I> From<SyncRequestBuilder<I>> for SyncRequest<I>
impl<I> From<SyncRequestBuilder<I>> for SyncRequest<I>
Source§fn from(builder: SyncRequestBuilder<I>) -> Self
fn from(builder: SyncRequestBuilder<I>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<I> Freeze for SyncRequestBuilder<I>
impl<I = ()> !RefUnwindSafe for SyncRequestBuilder<I>
impl<I> Send for SyncRequestBuilder<I>where
I: Send,
impl<I = ()> !Sync for SyncRequestBuilder<I>
impl<I> Unpin for SyncRequestBuilder<I>where
I: Unpin,
impl<I = ()> !UnwindSafe for SyncRequestBuilder<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more