stratus/eth/storage/permanent/
mod.rspub use self::rocks::RocksPermanentStorage;
pub use self::rocks::RocksStorageState;
pub mod rocks;
use std::time::Duration;
use clap::Parser;
use display_json::DebugAsJson;
#[cfg(feature = "dev")]
use crate::config::GenesisFileConfig;
use crate::ext::parse_duration;
#[derive(DebugAsJson, Clone, Parser, serde::Serialize)]
pub struct PermanentStorageConfig {
#[arg(long = "rocks-path-prefix", env = "ROCKS_PATH_PREFIX")]
pub rocks_path_prefix: Option<String>,
#[arg(long = "rocks-shutdown-timeout", env = "ROCKS_SHUTDOWN_TIMEOUT", value_parser=parse_duration, default_value = "4m")]
pub rocks_shutdown_timeout: Duration,
#[arg(long = "rocks-cache-size-multiplier", env = "ROCKS_CACHE_SIZE_MULTIPLIER")]
pub rocks_cache_size_multiplier: Option<f32>,
#[arg(long = "rocks-disable-sync-write", env = "ROCKS_DISABLE_SYNC_WRITE")]
pub rocks_disable_sync_write: bool,
#[arg(long = "use-rocksdb-replication", env = "USE_ROCKSDB_REPLICATION")]
pub use_rocksdb_replication: bool,
#[arg(long = "rocks-cf-size-metrics-interval", env = "ROCKS_CF_SIZE_METRICS_INTERVAL", value_parser=parse_duration)]
pub rocks_cf_size_metrics_interval: Option<Duration>,
#[clap(flatten)]
#[cfg(feature = "dev")]
pub genesis_file: GenesisFileConfig,
}
impl PermanentStorageConfig {
pub fn init(&self) -> anyhow::Result<RocksPermanentStorage> {
tracing::info!(config = ?self, "creating permanent storage");
RocksPermanentStorage::new(
self.rocks_path_prefix.clone(),
self.rocks_shutdown_timeout,
self.rocks_cache_size_multiplier,
!self.rocks_disable_sync_write,
self.use_rocksdb_replication,
self.rocks_cf_size_metrics_interval,
)
}
}