Struct bdk_chain::spk_client::SyncRequestBuilder

source ·
pub struct SyncRequestBuilder<I = ()> { /* private fields */ }
Expand description

Builds a SyncRequest.

Implementations§

source§

impl SyncRequestBuilder

source

pub fn spks( self, spks: impl IntoIterator<Item = ScriptBuf> ) -> SyncRequestBuilder

Add Scripts that will be synced against.

source§

impl<I> SyncRequestBuilder<I>

source

pub fn chain_tip(self, cp: CheckPoint) -> SyncRequestBuilder<I>

Set the initial chain tip for the sync request.

This is used to update LocalChain.

source

pub fn spks_with_indexes( self, spks: impl IntoIterator<Item = (I, ScriptBuf)> ) -> SyncRequestBuilder<I>

Add Scripts 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();
source

pub fn txids( self, txids: impl IntoIterator<Item = Txid> ) -> SyncRequestBuilder<I>

Add Txids that will be synced against.

source

pub fn outpoints( self, outpoints: impl IntoIterator<Item = OutPoint> ) -> SyncRequestBuilder<I>

Add OutPoints that will be synced against.

source

pub fn inspect<F>(self, inspect: F) -> SyncRequestBuilder<I>
where F: FnMut(SyncItem<'_, I>, SyncProgress) + Send + 'static,

Set the closure that will inspect every sync item visited.

source

pub fn build(self) -> SyncRequest<I>

Build the SyncRequest.

Trait Implementations§

source§

impl<I> Default for SyncRequestBuilder<I>

source§

fn default() -> SyncRequestBuilder<I>

Returns the “default value” for a type. Read more
source§

impl<I> From<SyncRequestBuilder<I>> for SyncRequest<I>

source§

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)>

source§

fn revealed_spks_from_indexer<R>( self, indexer: &KeychainTxOutIndex<K>, spk_range: R ) -> Self
where R: RangeBounds<K>,

Add Scripts that are revealed by the indexer of the given spk_range that will be synced against.
source§

fn unused_spks_from_indexer(self, indexer: &KeychainTxOutIndex<K>) -> Self

Add Scripts 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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V