better way to allow no config
This commit is contained in:
parent
51a9beaf6f
commit
ec5c28b64b
@ -117,45 +117,43 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let mut cli_config: Web3ProxyCli = argh::from_env();
|
let mut cli_config: Web3ProxyCli = argh::from_env();
|
||||||
|
|
||||||
if cli_config.config.is_none() && cli_config.db_url.is_none() {
|
if cli_config.config.is_none() && cli_config.db_url.is_none() && cli_config.sentry_url.is_none()
|
||||||
|
{
|
||||||
|
// TODO: default to example.toml if development.toml doesn't exist
|
||||||
info!("defaulting to development config");
|
info!("defaulting to development config");
|
||||||
cli_config.config = Some("./config/development.toml".to_string());
|
cli_config.config = Some("./config/development.toml".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let top_config = if let Some(top_config_path) = cli_config.config.clone() {
|
let top_config = if let Some(top_config_path) = cli_config.config.clone() {
|
||||||
if top_config_path.is_empty() {
|
let top_config_path = Path::new(&top_config_path)
|
||||||
None
|
.canonicalize()
|
||||||
} else {
|
.context(format!("checking for config at {}", top_config_path))?;
|
||||||
let top_config_path = Path::new(&top_config_path)
|
|
||||||
.canonicalize()
|
|
||||||
.context(format!("checking for config at {}", top_config_path))?;
|
|
||||||
|
|
||||||
let top_config: String = fs::read_to_string(top_config_path)?;
|
let top_config: String = fs::read_to_string(top_config_path)?;
|
||||||
let mut top_config: TopConfig = toml::from_str(&top_config)?;
|
let mut top_config: TopConfig = toml::from_str(&top_config)?;
|
||||||
|
|
||||||
// TODO: this doesn't seem to do anything
|
// TODO: this doesn't seem to do anything
|
||||||
proctitle::set_title(format!("web3_proxy-{}", top_config.app.chain_id));
|
proctitle::set_title(format!("web3_proxy-{}", top_config.app.chain_id));
|
||||||
|
|
||||||
if cli_config.db_url.is_none() {
|
if cli_config.db_url.is_none() {
|
||||||
cli_config.db_url = top_config.app.db_url.clone();
|
cli_config.db_url = top_config.app.db_url.clone();
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(sentry_url) = top_config.app.sentry_url.clone() {
|
|
||||||
cli_config.sentry_url = Some(sentry_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if top_config.app.chain_id == 137 {
|
|
||||||
if top_config.app.gas_increase_min.is_none() {
|
|
||||||
top_config.app.gas_increase_min = Some(U256::from(25_000));
|
|
||||||
}
|
|
||||||
|
|
||||||
if top_config.app.gas_increase_percent.is_none() {
|
|
||||||
top_config.app.gas_increase_percent = Some(U256::from(25));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(top_config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(sentry_url) = top_config.app.sentry_url.clone() {
|
||||||
|
cli_config.sentry_url = Some(sentry_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if top_config.app.chain_id == 137 {
|
||||||
|
if top_config.app.gas_increase_min.is_none() {
|
||||||
|
top_config.app.gas_increase_min = Some(U256::from(25_000));
|
||||||
|
}
|
||||||
|
|
||||||
|
if top_config.app.gas_increase_percent.is_none() {
|
||||||
|
top_config.app.gas_increase_percent = Some(U256::from(25));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(top_config)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user