bdk_core::spk_client

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

Add [Script]s that will be synced against.

Source§

impl<I> SyncRequestBuilder<I>

Source

pub fn chain_tip(self, cp: CheckPoint) -> Self

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

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

Add [Txid]s that will be synced against.

Source

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

Add [OutPoint]s that will be synced against.

Source

pub fn inspect<F>(self, inspect: F) -> Self
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() -> Self

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

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

Source§

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