Struct lightning_block_sync::SpvClient [−][src]
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]
L::Target: Listen,
pub fn new(
chain_tip: ValidatedBlockHeader,
chain_poller: P,
header_cache: &'a mut C,
chain_listener: L
) -> Self
[src]
chain_tip: ValidatedBlockHeader,
chain_poller: P,
header_cache: &'a mut C,
chain_listener: L
) -> Self
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 chainchain_listener
is notified of any blocks connected or disconnected
pub async fn poll_best_tip(
&mut self
) -> Result<(ChainTip, bool), BlockSourceError>
[src]
&mut self
) -> Result<(ChainTip, bool), BlockSourceError>
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,
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,
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,
C: Sync,
L: Sync,
P: Sync,
impl<'a, P, C, L> Unpin for SpvClient<'a, P, C, L> where
L: Unpin,
P: Unpin,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,