reth_provider/providers/database/
chain.rs
1use crate::{providers::NodeTypesForProvider, DatabaseProvider};
2use reth_db_api::transaction::{DbTx, DbTxMut};
3use reth_node_types::FullNodePrimitives;
4
5use reth_primitives_traits::{FullBlockHeader, FullSignedTx};
6use reth_storage_api::{ChainStorageReader, ChainStorageWriter, EthStorage};
7
8pub trait ChainStorage<Primitives: FullNodePrimitives>: Send + Sync {
10 fn reader<TX, Types>(&self) -> impl ChainStorageReader<DatabaseProvider<TX, Types>, Primitives>
12 where
13 TX: DbTx + 'static,
14 Types: NodeTypesForProvider<Primitives = Primitives>;
15
16 fn writer<TX, Types>(&self) -> impl ChainStorageWriter<DatabaseProvider<TX, Types>, Primitives>
18 where
19 TX: DbTxMut + DbTx + 'static,
20 Types: NodeTypesForProvider<Primitives = Primitives>;
21}
22
23impl<N, T, H> ChainStorage<N> for EthStorage<T, H>
24where
25 T: FullSignedTx,
26 H: FullBlockHeader,
27 N: FullNodePrimitives<
28 Block = alloy_consensus::Block<T, H>,
29 BlockHeader = H,
30 BlockBody = alloy_consensus::BlockBody<T, H>,
31 SignedTx = T,
32 >,
33{
34 fn reader<TX, Types>(&self) -> impl ChainStorageReader<DatabaseProvider<TX, Types>, N>
35 where
36 TX: DbTx + 'static,
37 Types: NodeTypesForProvider<Primitives = N>,
38 {
39 self
40 }
41
42 fn writer<TX, Types>(&self) -> impl ChainStorageWriter<DatabaseProvider<TX, Types>, N>
43 where
44 TX: DbTxMut + DbTx + 'static,
45 Types: NodeTypesForProvider<Primitives = N>,
46 {
47 self
48 }
49}