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,
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,
Sourcepub fn new(
full_verify_concurrency_limit: usize,
network: ZN,
verifier: ZV,
state: ZS,
latest_chain_tip: LatestChainTip,
) -> Self
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.
Sourcepub fn download_and_verify(&mut self, hash: Hash) -> DownloadAction
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.