revm_primitives/db/components/
block_hash.rs
1use crate::B256;
5use auto_impl::auto_impl;
6use core::ops::Deref;
7use std::sync::Arc;
8
9#[auto_impl(&mut, Box)]
10pub trait BlockHash {
11 type Error;
12
13 fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>;
15}
16
17#[auto_impl(&, &mut, Box, Rc, Arc)]
18pub trait BlockHashRef {
19 type Error;
20
21 fn block_hash(&self, number: u64) -> Result<B256, Self::Error>;
23}
24
25impl<T> BlockHash for &T
26where
27 T: BlockHashRef,
28{
29 type Error = <T as BlockHashRef>::Error;
30
31 fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error> {
32 BlockHashRef::block_hash(*self, number)
33 }
34}
35
36impl<T> BlockHash for Arc<T>
37where
38 T: BlockHashRef,
39{
40 type Error = <T as BlockHashRef>::Error;
41
42 fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error> {
43 self.deref().block_hash(number)
44 }
45}