Skip to content

Commit

Permalink
fix: remove unnecessary wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich committed Oct 28, 2024
1 parent 8104bfe commit a14a377
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 0 additions & 20 deletions examples/database_components/src/block_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,3 @@ where
self.deref().block_hash(number)
}
}

/// Wraps a [`BlockHashRef`] to provide a [`BlockHash`] implementation.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WrapBlockHashRef<T: BlockHashRef>(pub T);

impl<F: BlockHashRef> From<F> for WrapBlockHashRef<F> {
#[inline]
fn from(f: F) -> Self {
WrapBlockHashRef(f)
}
}

impl<T: BlockHashRef> BlockHash for WrapBlockHashRef<T> {
type Error = T::Error;

#[inline]
fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error> {
self.0.block_hash(number)
}
}
3 changes: 1 addition & 2 deletions examples/database_components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
pub mod block_hash;
pub mod state;

use block_hash::WrapBlockHashRef;
pub use block_hash::{BlockHash, BlockHashRef};
pub use state::{State, StateRef};

Expand Down Expand Up @@ -72,7 +71,7 @@ impl<S: State, BH: BlockHashRef> Database for DatabaseComponents<S, BH> {
}

fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error> {
WrapBlockHashRef(&self.block_hash)
self.block_hash
.block_hash(number)
.map_err(Self::Error::BlockHash)
}
Expand Down

0 comments on commit a14a377

Please sign in to comment.