-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use
NoopBodiesDownloader
& NoopHeaderDownloader
on `stage …
…unwind` command (#8165)
- Loading branch information
Showing
5 changed files
with
70 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use futures::Stream; | ||
use reth_interfaces::p2p::{ | ||
bodies::{downloader::BodyDownloader, response::BlockResponse}, | ||
error::{DownloadError, DownloadResult}, | ||
}; | ||
use reth_primitives::BlockNumber; | ||
use std::ops::RangeInclusive; | ||
|
||
/// A [BodyDownloader] implementation that does nothing. | ||
#[derive(Debug, Default)] | ||
#[non_exhaustive] | ||
pub struct NoopBodiesDownloader; | ||
|
||
impl BodyDownloader for NoopBodiesDownloader { | ||
fn set_download_range(&mut self, _: RangeInclusive<BlockNumber>) -> DownloadResult<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Stream for NoopBodiesDownloader { | ||
type Item = Result<Vec<BlockResponse>, DownloadError>; | ||
|
||
fn poll_next( | ||
self: std::pin::Pin<&mut Self>, | ||
_: &mut std::task::Context<'_>, | ||
) -> std::task::Poll<Option<Self::Item>> { | ||
panic!("NoopBodiesDownloader shouldn't be polled.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use futures::Stream; | ||
use reth_interfaces::p2p::headers::{ | ||
downloader::{HeaderDownloader, SyncTarget}, | ||
error::HeadersDownloaderError, | ||
}; | ||
use reth_primitives::SealedHeader; | ||
|
||
/// A [HeaderDownloader] implementation that does nothing. | ||
#[derive(Debug, Default)] | ||
#[non_exhaustive] | ||
pub struct NoopHeaderDownloader; | ||
|
||
impl HeaderDownloader for NoopHeaderDownloader { | ||
fn update_local_head(&mut self, _: SealedHeader) {} | ||
|
||
fn update_sync_target(&mut self, _: SyncTarget) {} | ||
|
||
fn set_batch_size(&mut self, _: usize) {} | ||
} | ||
|
||
impl Stream for NoopHeaderDownloader { | ||
type Item = Result<Vec<SealedHeader>, HeadersDownloaderError>; | ||
|
||
fn poll_next( | ||
self: std::pin::Pin<&mut Self>, | ||
_: &mut std::task::Context<'_>, | ||
) -> std::task::Poll<Option<Self::Item>> { | ||
panic!("NoopHeaderDownloader shouldn't be polled.") | ||
} | ||
} |