Struct bdk_chain::spk_client::SyncRequest

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

Data required to perform a spk-based blockchain client sync.

A client sync fetches relevant chain data for a known list of scripts, transaction ids and outpoints. The sync process also updates the chain from the given chain_tip (if provided).

// Construct a sync request.
let sync_request = SyncRequest::builder()
    // Provide chain tip of the local wallet.
    .chain_tip(local_chain.tip())
    // Provide list of scripts to scan for transactions against.
    .spks(scripts)
    // This is called for every synced item.
    .inspect(|item, progress| println!("{} (remaining: {})", item, progress.remaining()))
    // Finish constructing the sync request.
    .build();

Implementations§

source§

impl<I> SyncRequest<I>

source

pub fn builder() -> SyncRequestBuilder<I>

Start building a SyncRequest.

source

pub fn progress(&self) -> SyncProgress

Get the SyncProgress of this request.

source

pub fn chain_tip(&self) -> Option<CheckPoint>

Get the chain tip CheckPoint of this request (if any).

source

pub fn next_spk(&mut self) -> Option<ScriptBuf>

Advances the sync request and returns the next ScriptBuf.

Returns None when there are no more scripts remaining in the request.

source

pub fn next_txid(&mut self) -> Option<Txid>

Advances the sync request and returns the next Txid.

Returns None when there are no more txids remaining in the request.

source

pub fn next_outpoint(&mut self) -> Option<OutPoint>

Advances the sync request and returns the next OutPoint.

Returns None when there are no more outpoints in the request.

source

pub fn iter_spks(&mut self) -> impl ExactSizeIterator

Iterate over ScriptBufs contained in this request.

source

pub fn iter_txids(&mut self) -> impl ExactSizeIterator

Iterate over Txids contained in this request.

source

pub fn iter_outpoints(&mut self) -> impl ExactSizeIterator

Iterate over OutPoints contained in this request.

Trait Implementations§

source§

impl<I> Default for SyncRequest<I>

source§

fn default() -> SyncRequest<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.

Auto Trait Implementations§

§

impl<I> Freeze for SyncRequest<I>

§

impl<I = ()> !RefUnwindSafe for SyncRequest<I>

§

impl<I> Send for SyncRequest<I>
where I: Send,

§

impl<I = ()> !Sync for SyncRequest<I>

§

impl<I> Unpin for SyncRequest<I>
where I: Unpin,

§

impl<I = ()> !UnwindSafe for SyncRequest<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