Struct lightning_block_sync::SpvClient[][src]

pub struct SpvClient<'a, P: Poll, C: Cache, L: Deref> where
    L::Target: Listen
{ /* fields omitted */ }

A lightweight client for keeping a listener in sync with the chain, allowing for Simplified Payment Verification (SPV).

The client is parameterized by a chain poller which is responsible for polling one or more block sources for the best chain tip. During this process it detects any chain forks, determines which constitutes the best chain, and updates the listener accordingly with any blocks that were connected or disconnected since the last poll.

Block headers for the best chain are maintained in the parameterized cache, allowing for a custom cache eviction policy. This offers flexibility to those sensitive to resource usage. Hence, there is a trade-off between a lower memory footprint and potentially increased network I/O as headers are re-fetched during fork detection.

Implementations

impl<'a, P: Poll, C: Cache, L: Deref> SpvClient<'a, P, C, L> where
    L::Target: Listen
[src]

pub fn new(
    chain_tip: ValidatedBlockHeader,
    chain_poller: P,
    header_cache: &'a mut C,
    chain_listener: L
) -> Self
[src]

Creates a new SPV client using chain_tip as the best known chain tip.

Subsequent calls to poll_best_tip will poll for the best chain tip using the given chain poller, which may be configured with one or more block sources to query. At least one block source must provide headers back from the best chain tip to its common ancestor with chain_tip.

  • header_cache is used to look up and store headers on the best chain
  • chain_listener is notified of any blocks connected or disconnected

pub async fn poll_best_tip(
    &mut self
) -> Result<(ChainTip, bool), BlockSourceError>
[src]

Polls for the best tip and updates the chain listener with any connected or disconnected blocks accordingly.

Returns the best polled chain tip relative to the previous best known tip and whether any blocks were indeed connected or disconnected.

Auto Trait Implementations

impl<'a, P, C, L> RefUnwindSafe for SpvClient<'a, P, C, L> where
    C: RefUnwindSafe,
    L: RefUnwindSafe,
    P: RefUnwindSafe

impl<'a, P, C, L> Send for SpvClient<'a, P, C, L> where
    C: Send,
    L: Send,
    P: Send

impl<'a, P, C, L> Sync for SpvClient<'a, P, C, L> where
    C: Sync,
    L: Sync,
    P: Sync

impl<'a, P, C, L> Unpin for SpvClient<'a, P, C, L> where
    L: Unpin,
    P: Unpin

impl<'a, P, C, L> !UnwindSafe for SpvClient<'a, P, C, L>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.