reth_storage_api/block_hash.rs
1use alloc::vec::Vec;
2use alloy_primitives::{BlockNumber, B256};
3use reth_storage_errors::provider::ProviderResult;
4
5/// Client trait for fetching block hashes by number.
6#[auto_impl::auto_impl(&, Box, Arc)]
7pub trait BlockHashReader {
8 /// Get the hash of the block with the given number. Returns `None` if no block with this number
9 /// exists.
10 fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>;
11
12 /// Get headers in range of block hashes or numbers
13 ///
14 /// Returns the available hashes of that range.
15 ///
16 /// Note: The range is `start..end`, so the expected result is `[start..end)`
17 fn canonical_hashes_range(
18 &self,
19 start: BlockNumber,
20 end: BlockNumber,
21 ) -> ProviderResult<Vec<B256>>;
22}