dep: rm confy as a dep (#10290)

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
Thomas Coratger
2024-08-19 23:37:35 -07:00
committed by GitHub
parent 56e1448dbd
commit cd05a96fee
13 changed files with 187 additions and 49 deletions

View File

@ -58,7 +58,6 @@ secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recov
# io
fdlimit.workspace = true
confy.workspace = true
toml = { workspace = true, features = ["display"] }
# tui

View File

@ -65,7 +65,8 @@ impl EnvironmentArgs {
}
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
let mut config: Config = confy::load_path(config_path)
let mut config = Config::from_path(config_path)
.inspect_err(
|err| warn!(target: "reth::cli", %err, "Failed to load config file, using default"),
)

View File

@ -25,11 +25,12 @@ impl Command {
Config::default()
} else {
let path = self.config.clone().unwrap_or_default();
// confy will create the file if it doesn't exist; we don't want this
// Check if the file exists
if !path.exists() {
bail!("Config file does not exist: {}", path.display());
}
confy::load_path::<Config>(&path)
// Read the configuration file
Config::from_path(&path)
.wrap_err_with(|| format!("Could not load config file: {}", path.display()))?
};
println!("{}", toml::to_string_pretty(&config)?);

View File

@ -74,13 +74,15 @@ pub enum Subcommands {
// RLPx utilities
Rlpx(rlpx::Command),
}
impl Command {
/// Execute `p2p` command
pub async fn execute(self) -> eyre::Result<()> {
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
let mut config: Config = confy::load_path(&config_path).unwrap_or_default();
// Load configuration
let mut config = Config::from_path(&config_path).unwrap_or_default();
config.peers.trusted_nodes.extend(self.network.trusted_peers.clone());