-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split Database trait into sub-traits
- Loading branch information
Showing
15 changed files
with
279 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use auto_impl::auto_impl; | ||
use revm_interpreter::{B256, U256}; | ||
|
||
#[auto_impl(& mut, Box)] | ||
pub trait BlockHash { | ||
type Error; | ||
|
||
/// Get block hash by block number | ||
fn block_hash(&mut self, number: U256) -> Result<B256, Self::Error>; | ||
} | ||
|
||
#[auto_impl(&, Box, Arc)] | ||
pub trait BlockHashRef { | ||
type Error; | ||
|
||
/// Get block hash by block number | ||
fn block_hash(&self, number: U256) -> Result<B256, Self::Error>; | ||
} | ||
|
||
impl<T> BlockHash for &T | ||
where | ||
T: BlockHashRef, | ||
{ | ||
type Error = <T as BlockHashRef>::Error; | ||
|
||
fn block_hash(&mut self, number: U256) -> Result<B256, Self::Error> { | ||
BlockHashRef::block_hash(*self, number) | ||
} | ||
} |
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
Oops, something went wrong.