reth_network_p2p/bodies/
downloader.rs

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