[][src]Struct zebrad::components::sync::downloads::Downloads

pub struct Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
{ network: ZN, verifier: ZV, pending: FuturesUnordered<JoinHandle<Result<Hash, (Box<dyn Error + Send + Sync + 'static>, Hash)>>>, cancel_handles: HashMap<Hash, Sender<()>>, }

Represents a Stream of download and verification tasks during chain sync.

Fields

network: ZNverifier: ZVpending: FuturesUnordered<JoinHandle<Result<Hash, (Box<dyn Error + Send + Sync + 'static>, Hash)>>>cancel_handles: HashMap<Hash, Sender<()>>

Implementations

impl<ZN, ZV> Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

pub fn new(network: ZN, verifier: ZV) -> Self[src]

Initialize a new download stream with the provided network and verifier services.

The Downloads stream is agnostic to the network policy, so retry and timeout limits should be applied to the network service passed into this constructor.

pub async fn download_and_verify<'_>(
    &'_ mut self,
    hash: Hash
) -> Result<(), Report>
[src]

Queue a block for download and verification.

This method waits for the network to become ready, and returns an error only if the network service fails. It returns immediately after queuing the request.

pub fn cancel_all(&mut self)[src]

Cancel all running tasks and reset the downloader state.

pub fn in_flight(&self) -> usize[src]

Get the number of currently in-flight download tasks.

Trait Implementations

impl<ZN: Debug, ZV: Debug> Debug for Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

impl<ZN, ZV> PinnedDrop for Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

impl<ZN, ZV> Stream for Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

type Item = Result<Hash, Box<dyn Error + Send + Sync + 'static>>

Values yielded by the stream.

impl<'pin, ZN, ZV> Unpin for Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send,
    __Downloads<'pin, ZN, ZV>: Unpin
[src]

impl<ZN, ZV> UnsafeUnpin for Downloads<ZN, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + 'static,
    ZN::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

Auto Trait Implementations

impl<ZN, ZV> !RefUnwindSafe for Downloads<ZN, ZV>

impl<ZN, ZV> Send for Downloads<ZN, ZV>

impl<ZN, ZV> Sync for Downloads<ZN, ZV> where
    ZN: Sync,
    ZV: Sync

impl<ZN, ZV> !UnwindSafe for Downloads<ZN, ZV>

Blanket Implementations

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

impl<T> AsAny for T where
    T: Any
[src]

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

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

impl<T> Conv for T

impl<T> Erased for T

impl<T> FmtForward for T

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<D> OwoColorize for D

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<St> StreamExt for St where
    St: Stream + ?Sized
[src]

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

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.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]