stratus/eth/storage/permanent/
mod.rs1pub use self::rocks::RocksPermanentStorage;
2pub use self::rocks::RocksStorageState;
3
4pub mod rocks;
5
6use std::time::Duration;
7
8use clap::Parser;
9use display_json::DebugAsJson;
10
11#[cfg(feature = "dev")]
13use crate::config::GenesisFileConfig;
14use crate::ext::parse_duration;
15
16#[derive(DebugAsJson, Clone, Parser, serde::Serialize)]
22pub struct PermanentStorageConfig {
23 #[arg(long = "rocks-path-prefix", env = "ROCKS_PATH_PREFIX")]
25 pub rocks_path_prefix: Option<String>,
26
27 #[arg(long = "rocks-shutdown-timeout", env = "ROCKS_SHUTDOWN_TIMEOUT", value_parser=parse_duration, default_value = "4m")]
29 pub rocks_shutdown_timeout: Duration,
30
31 #[arg(long = "rocks-cache-size-multiplier", env = "ROCKS_CACHE_SIZE_MULTIPLIER")]
33 pub rocks_cache_size_multiplier: Option<f32>,
34
35 #[arg(long = "rocks-disable-sync-write", env = "ROCKS_DISABLE_SYNC_WRITE")]
37 pub rocks_disable_sync_write: bool,
38
39 #[arg(long = "rocks-cf-size-metrics-interval", env = "ROCKS_CF_SIZE_METRICS_INTERVAL", value_parser=parse_duration)]
41 pub rocks_cf_size_metrics_interval: Option<Duration>,
42
43 #[arg(long = "rocks-file-descriptors-limit", env = "ROCKS_FILE_DESCRIPTORS_LIMIT", default_value = Self::DEFAULT_FILE_DESCRIPTORS_LIMIT)]
45 pub rocks_file_descriptors_limit: u64,
46
47 #[clap(flatten)]
49 #[cfg(feature = "dev")]
50 pub genesis_file: GenesisFileConfig,
51}
52
53impl PermanentStorageConfig {
54 const DEFAULT_FILE_DESCRIPTORS_LIMIT: &'static str = if cfg!(feature = "dev") { "65536" } else { "1048576" };
55 pub fn init(&self) -> anyhow::Result<RocksPermanentStorage> {
57 tracing::info!(config = ?self, "creating permanent storage");
58
59 RocksPermanentStorage::new(
60 self.rocks_path_prefix.clone(),
61 self.rocks_shutdown_timeout,
62 self.rocks_cache_size_multiplier,
63 !self.rocks_disable_sync_write,
64 self.rocks_cf_size_metrics_interval,
65 self.rocks_file_descriptors_limit,
66 )
67 }
68}