Type Alias GossipedBlockDownloads

Source
type GossipedBlockDownloads = Downloads<Timeout<Buffer<BoxService<Request, Response, BoxError>, Request>>, Timeout<Buffer<BoxService<Request, Hash, RouterError>, Request>>, Buffer<BoxService<Request, Response, BoxError>, Request>>;

Aliased Type§

struct GossipedBlockDownloads {
    full_verify_concurrency_limit: usize,
    network: Timeout<Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>>,
    verifier: Timeout<Buffer<BoxService<Request, Hash, RouterError>, Request>>,
    state: Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>,
    latest_chain_tip: LatestChainTip,
    pending: FuturesUnordered<JoinHandle<Result<Hash, (Box<dyn Error + Send + Sync>, Hash, Option<PeerSocketAddr>)>>>,
    cancel_handles: HashMap<Hash, Sender<()>>,
}

Fields§

§full_verify_concurrency_limit: usize

The configured full verification concurrency limit, after applying the minimum limit.

§network: Timeout<Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>>

A service that forwards requests to connected peers, and returns their responses.

§verifier: Timeout<Buffer<BoxService<Request, Hash, RouterError>, Request>>

A service that verifies downloaded blocks.

§state: Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>

A service that manages cached blockchain state.

§latest_chain_tip: LatestChainTip

Allows efficient access to the best tip of the blockchain.

§pending: FuturesUnordered<JoinHandle<Result<Hash, (Box<dyn Error + Send + Sync>, Hash, Option<PeerSocketAddr>)>>>

A list of pending block download and verify tasks.

§cancel_handles: HashMap<Hash, Sender<()>>

A list of channels that can be used to cancel pending block download and verify tasks.

Implementations

Source§

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

Source

pub fn new( full_verify_concurrency_limit: usize, network: ZN, verifier: ZV, state: ZS, latest_chain_tip: LatestChainTip, ) -> Self

Initialize a new download stream with the provided network, verifier, and state services. The latest_chain_tip must be linked to the provided state service.

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.

Source

pub fn download_and_verify(&mut self, hash: Hash) -> DownloadAction

Queue a block for download and verification.

Returns the action taken in response to the queue request.

Source§

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

Source

pub(crate) fn project<'pin>( self: Pin<&'pin mut Self>, ) -> __DownloadsProjection<'pin, ZN, ZV, ZS>

Source

pub(crate) fn project_ref<'pin>( self: Pin<&'pin Self>, ) -> __DownloadsProjectionRef<'pin, ZN, ZV, ZS>

Trait Implementations

Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

type Item = Result<Hash, (Box<dyn Error + Send + Sync>, Option<PeerSocketAddr>)>

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Source§

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