reth_provider/providers/database/
chain.rs

1use crate::{providers::NodeTypesForProvider, DatabaseProvider};
2use reth_db::transaction::{DbTx, DbTxMut};
3use reth_node_types::FullNodePrimitives;
4use reth_primitives::EthPrimitives;
5use reth_storage_api::{ChainStorageReader, ChainStorageWriter, EthStorage};
6
7/// Trait that provides access to implementations of [`ChainStorage`]
8pub trait ChainStorage<Primitives: FullNodePrimitives>: Send + Sync {
9    /// Provides access to the chain reader.
10    fn reader<TX, Types>(&self) -> impl ChainStorageReader<DatabaseProvider<TX, Types>, Primitives>
11    where
12        TX: DbTx + 'static,
13        Types: NodeTypesForProvider<Primitives = Primitives>;
14
15    /// Provides access to the chain writer.
16    fn writer<TX, Types>(&self) -> impl ChainStorageWriter<DatabaseProvider<TX, Types>, Primitives>
17    where
18        TX: DbTxMut + DbTx + 'static,
19        Types: NodeTypesForProvider<Primitives = Primitives>;
20}
21
22impl ChainStorage<EthPrimitives> for EthStorage {
23    fn reader<TX, Types>(
24        &self,
25    ) -> impl ChainStorageReader<DatabaseProvider<TX, Types>, EthPrimitives>
26    where
27        TX: DbTx + 'static,
28        Types: NodeTypesForProvider<Primitives = EthPrimitives>,
29    {
30        self
31    }
32
33    fn writer<TX, Types>(
34        &self,
35    ) -> impl ChainStorageWriter<DatabaseProvider<TX, Types>, EthPrimitives>
36    where
37        TX: DbTxMut + DbTx + 'static,
38        Types: NodeTypesForProvider<Primitives = EthPrimitives>,
39    {
40        self
41    }
42}