Struct SyncRequestBuilder
pub struct SyncRequestBuilder<I = ()> { /* private fields */ }
Expand description
Builds a SyncRequest
.
Implementations§
§impl SyncRequestBuilder
impl SyncRequestBuilder
pub fn spks(
self,
spks: impl IntoIterator<Item = ScriptBuf>,
) -> SyncRequestBuilder
pub fn spks( self, spks: impl IntoIterator<Item = ScriptBuf>, ) -> SyncRequestBuilder
Add Script
s that will be synced against.
§impl<I> SyncRequestBuilder<I>
impl<I> SyncRequestBuilder<I>
pub fn chain_tip(self, cp: CheckPoint) -> SyncRequestBuilder<I>
pub fn chain_tip(self, cp: CheckPoint) -> SyncRequestBuilder<I>
Set the initial chain tip for the sync request.
This is used to update LocalChain
.
pub fn spks_with_indexes(
self,
spks: impl IntoIterator<Item = (I, ScriptBuf)>,
) -> SyncRequestBuilder<I>
pub fn spks_with_indexes( self, spks: impl IntoIterator<Item = (I, ScriptBuf)>, ) -> SyncRequestBuilder<I>
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();
pub fn txids(
self,
txids: impl IntoIterator<Item = Txid>,
) -> SyncRequestBuilder<I>
pub fn txids( self, txids: impl IntoIterator<Item = Txid>, ) -> SyncRequestBuilder<I>
Add Txid
s that will be synced against.
pub fn outpoints(
self,
outpoints: impl IntoIterator<Item = OutPoint>,
) -> SyncRequestBuilder<I>
pub fn outpoints( self, outpoints: impl IntoIterator<Item = OutPoint>, ) -> SyncRequestBuilder<I>
Add OutPoint
s that will be synced against.
pub fn inspect<F>(self, inspect: F) -> SyncRequestBuilder<I>
pub fn inspect<F>(self, inspect: F) -> SyncRequestBuilder<I>
Set the closure that will inspect every sync item visited.
pub fn build(self) -> SyncRequest<I>
pub fn build(self) -> SyncRequest<I>
Build the SyncRequest
.
Trait Implementations§
§impl<I> Default for SyncRequestBuilder<I>
impl<I> Default for SyncRequestBuilder<I>
§fn default() -> SyncRequestBuilder<I>
fn default() -> SyncRequestBuilder<I>
Returns the “default value” for a type. Read more
§impl<I> From<SyncRequestBuilder<I>> for SyncRequest<I>
impl<I> From<SyncRequestBuilder<I>> for SyncRequest<I>
§fn from(builder: SyncRequestBuilder<I>) -> SyncRequest<I>
fn from(builder: SyncRequestBuilder<I>) -> SyncRequest<I>
Converts to this type from the input type.
Source§impl<K: Clone + Ord + Debug> SyncRequestBuilderExt<K> for SyncRequestBuilder<(K, u32)>
impl<K: Clone + Ord + Debug> SyncRequestBuilderExt<K> for SyncRequestBuilder<(K, u32)>
Source§fn revealed_spks_from_indexer<R>(
self,
indexer: &KeychainTxOutIndex<K>,
spk_range: R,
) -> Selfwhere
R: RangeBounds<K>,
fn revealed_spks_from_indexer<R>(
self,
indexer: &KeychainTxOutIndex<K>,
spk_range: R,
) -> Selfwhere
R: RangeBounds<K>,
Source§fn unused_spks_from_indexer(self, indexer: &KeychainTxOutIndex<K>) -> Self
fn unused_spks_from_indexer(self, indexer: &KeychainTxOutIndex<K>) -> Self
Add
Script
s that are revealed by the indexer
but currently unused.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