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:
17    Send + Sync + Stream<Item = BodyDownloaderResult<Self::Block>> + Unpin
18{
19    /// The Block type this downloader supports
20    type Block: Block + 'static;
21
22    /// Method for setting the download range.
23    fn set_download_range(&mut self, range: RangeInclusive<BlockNumber>) -> DownloadResult<()>;
24}