reth_trie/hashed_cursor/
mod.rs1use alloy_primitives::{B256, U256};
2use reth_primitives_traits::Account;
3use reth_storage_errors::db::DatabaseError;
4
5mod post_state;
7pub use post_state::*;
8
9pub mod noop;
11
12#[cfg(test)]
14pub mod mock;
15
16#[auto_impl::auto_impl(&)]
18pub trait HashedCursorFactory {
19 type AccountCursor<'a>: HashedCursor<Value = Account>
21 where
22 Self: 'a;
23 type StorageCursor<'a>: HashedStorageCursor<Value = U256>
25 where
26 Self: 'a;
27
28 fn hashed_account_cursor(&self) -> Result<Self::AccountCursor<'_>, DatabaseError>;
30
31 fn hashed_storage_cursor(
33 &self,
34 hashed_address: B256,
35 ) -> Result<Self::StorageCursor<'_>, DatabaseError>;
36}
37
38#[auto_impl::auto_impl(&mut)]
40pub trait HashedCursor {
41 type Value: std::fmt::Debug;
43
44 fn seek(&mut self, key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError>;
47
48 fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError>;
50}
51
52#[auto_impl::auto_impl(&mut)]
54pub trait HashedStorageCursor: HashedCursor {
55 fn is_storage_empty(&mut self) -> Result<bool, DatabaseError>;
57}