bdk_chain::spk_client

Struct SyncRequestBuilder

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

Builds a SyncRequest.

Implementations§

§

impl SyncRequestBuilder

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

Add Scripts that will be synced against.

§

impl<I> 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>

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

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

Add Txids that will be synced against.

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

Add OutPoints that will be synced against.

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.

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

Build the SyncRequest.

Trait Implementations§

§

impl<I> Default for SyncRequestBuilder<I>

§

fn default() -> SyncRequestBuilder<I>

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

impl<I> From<SyncRequestBuilder<I>> for 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)>

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

Source§

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

Source§

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