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

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

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

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.