reth_network_p2p/bodies/downloader.rs
1use super::response::BlockResponse;
2use crate::error::DownloadResult;
3use alloy_primitives::BlockNumber;
4use futures::Stream;
5use std::{fmt::Debug, ops::RangeInclusive};
6
7/// Body downloader return type.
8pub type BodyDownloaderResult<H, B> = DownloadResult<Vec<BlockResponse<H, B>>>;
9
10/// A downloader capable of fetching and yielding block bodies from block headers.
11///
12/// A downloader represents a distinct strategy for submitting requests to download block bodies,
13/// while a [`BodiesClient`][crate::bodies::client::BodiesClient] represents a client capable of
14/// fulfilling these requests.
15pub trait BodyDownloader:
16 Send + Sync + Stream<Item = BodyDownloaderResult<Self::Header, Self::Body>> + Unpin
17{
18 /// The type of header that is being used
19 type Header: Debug + Send + Sync + Unpin + 'static;
20
21 /// The type of the body that is being downloaded.
22 type Body: Debug + Send + Sync + Unpin + 'static;
23
24 /// Method for setting the download range.
25 fn set_download_range(&mut self, range: RangeInclusive<BlockNumber>) -> DownloadResult<()>;
26}