reth_rpc_eth_types/cache/
config.rs

1//! Configuration for RPC cache.
2
3use serde::{Deserialize, Serialize};
4
5use reth_rpc_server_types::constants::cache::{
6    DEFAULT_BLOCK_CACHE_MAX_LEN, DEFAULT_CONCURRENT_DB_REQUESTS, DEFAULT_HEADER_CACHE_MAX_LEN,
7    DEFAULT_RECEIPT_CACHE_MAX_LEN,
8};
9
10/// Settings for the [`EthStateCache`](super::EthStateCache).
11#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub struct EthStateCacheConfig {
14    /// Max number of blocks in cache.
15    ///
16    /// Default is 5000.
17    pub max_blocks: u32,
18    /// Max number receipts in cache.
19    ///
20    /// Default is 2000.
21    pub max_receipts: u32,
22    /// Max number of headers in cache.
23    ///
24    /// Default is 1000.
25    pub max_headers: u32,
26    /// Max number of concurrent database requests.
27    ///
28    /// Default is 512.
29    pub max_concurrent_db_requests: usize,
30}
31
32impl Default for EthStateCacheConfig {
33    fn default() -> Self {
34        Self {
35            max_blocks: DEFAULT_BLOCK_CACHE_MAX_LEN,
36            max_receipts: DEFAULT_RECEIPT_CACHE_MAX_LEN,
37            max_headers: DEFAULT_HEADER_CACHE_MAX_LEN,
38            max_concurrent_db_requests: DEFAULT_CONCURRENT_DB_REQUESTS,
39        }
40    }
41}