reth_trie/hashed_cursor/
noop.rs1use super::{HashedCursor, HashedCursorFactory, HashedStorageCursor};
2use alloy_primitives::{B256, U256};
3use reth_primitives_traits::Account;
4use reth_storage_errors::db::DatabaseError;
5
6#[derive(Clone, Default, Debug)]
8#[non_exhaustive]
9pub struct NoopHashedCursorFactory;
10
11impl HashedCursorFactory for NoopHashedCursorFactory {
12 type AccountCursor<'a>
13 = NoopHashedAccountCursor
14 where
15 Self: 'a;
16 type StorageCursor<'a>
17 = NoopHashedStorageCursor
18 where
19 Self: 'a;
20
21 fn hashed_account_cursor(&self) -> Result<Self::AccountCursor<'_>, DatabaseError> {
22 Ok(NoopHashedAccountCursor::default())
23 }
24
25 fn hashed_storage_cursor(
26 &self,
27 _hashed_address: B256,
28 ) -> Result<Self::StorageCursor<'_>, DatabaseError> {
29 Ok(NoopHashedStorageCursor::default())
30 }
31}
32
33#[derive(Default, Debug)]
35#[non_exhaustive]
36pub struct NoopHashedAccountCursor;
37
38impl HashedCursor for NoopHashedAccountCursor {
39 type Value = Account;
40
41 fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
42 Ok(None)
43 }
44
45 fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
46 Ok(None)
47 }
48}
49
50#[derive(Default, Debug)]
52#[non_exhaustive]
53pub struct NoopHashedStorageCursor;
54
55impl HashedCursor for NoopHashedStorageCursor {
56 type Value = U256;
57
58 fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
59 Ok(None)
60 }
61
62 fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
63 Ok(None)
64 }
65}
66
67impl HashedStorageCursor for NoopHashedStorageCursor {
68 fn is_storage_empty(&mut self) -> Result<bool, DatabaseError> {
69 Ok(true)
70 }
71}