use std::path::PathBuf;
use primitive_types::H256;
use std::str::FromStr;
pub mod account_key;
#[derive(Debug, Copy, Clone)]
pub enum Sealing {
Instant,
Manual,
Interval(u64),
}
impl FromStr for Sealing {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"instant" => Self::Instant,
"manual" => Self::Manual,
s => {
let millis =
u64::from_str_radix(s, 10).map_err(|_| "couldn't decode sealing param")?;
Self::Interval(millis)
}
})
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum EthApi {
Txpool,
Debug,
Trace,
}
impl FromStr for EthApi {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"txpool" => Self::Txpool,
"debug" => Self::Debug,
"trace" => Self::Trace,
_ => {
return Err(format!(
"`{}` is not recognized as a supported Ethereum Api",
s
))
}
})
}
}
#[derive(Debug, Copy, Clone, Default, clap::ValueEnum)]
pub enum FrontierBackendType {
#[default]
KeyValue,
Sql,
}
pub enum FrontierBackendConfig {
KeyValue,
Sql {
pool_size: u32,
num_ops_timeout: u32,
thread_count: u32,
cache_size: u64,
},
}
impl Default for FrontierBackendConfig {
fn default() -> FrontierBackendConfig {
FrontierBackendConfig::KeyValue
}
}
pub struct RpcConfig {
pub ethapi: Vec<EthApi>,
pub ethapi_max_permits: u32,
pub ethapi_trace_max_count: u32,
pub ethapi_trace_cache_duration: u64,
pub eth_log_block_cache: usize,
pub eth_statuses_cache: usize,
pub fee_history_limit: u64,
pub max_past_logs: u32,
pub relay_chain_rpc_urls: Vec<url::Url>,
pub tracing_raw_max_memory_usage: usize,
pub frontier_backend_config: FrontierBackendConfig,
pub no_prometheus_prefix: bool,
}
#[derive(Clone)]
pub struct LazyLoadingConfig {
pub state_rpc: String,
pub from_block: Option<H256>,
pub state_overrides_path: Option<PathBuf>,
pub runtime_override: Option<PathBuf>,
}