-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add non feature gated noop block reader (#9261)
- Loading branch information
Showing
10 changed files
with
62 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -51,3 +51,5 @@ pub use trie::*; | |
|
||
mod withdrawals; | ||
pub use withdrawals::*; | ||
|
||
pub mod noop; |
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,44 @@ | ||
//! Various noop implementations for traits. | ||
use crate::{BlockHashReader, BlockNumReader}; | ||
use reth_chainspec::ChainInfo; | ||
use reth_primitives::{BlockNumber, B256}; | ||
use reth_storage_errors::provider::ProviderResult; | ||
|
||
/// Supports various api interfaces for testing purposes. | ||
#[derive(Debug, Clone, Default, Copy)] | ||
#[non_exhaustive] | ||
pub struct NoopBlockReader; | ||
|
||
/// Noop implementation for testing purposes | ||
impl BlockHashReader for NoopBlockReader { | ||
fn block_hash(&self, _number: u64) -> ProviderResult<Option<B256>> { | ||
Ok(None) | ||
} | ||
|
||
fn canonical_hashes_range( | ||
&self, | ||
_start: BlockNumber, | ||
_end: BlockNumber, | ||
) -> ProviderResult<Vec<B256>> { | ||
Ok(vec![]) | ||
} | ||
} | ||
|
||
impl BlockNumReader for NoopBlockReader { | ||
fn chain_info(&self) -> ProviderResult<ChainInfo> { | ||
Ok(ChainInfo::default()) | ||
} | ||
|
||
fn best_block_number(&self) -> ProviderResult<BlockNumber> { | ||
Ok(0) | ||
} | ||
|
||
fn last_block_number(&self) -> ProviderResult<BlockNumber> { | ||
Ok(0) | ||
} | ||
|
||
fn block_number(&self, _hash: B256) -> ProviderResult<Option<BlockNumber>> { | ||
Ok(None) | ||
} | ||
} |