fix(cli) Allow Pruning CLI Args to take precedence over TOML configuration (#10774)

Co-authored-by: garwah <garwah@garwah>
This commit is contained in:
garwah
2024-09-17 20:01:32 +10:00
committed by GitHub
parent 1d0b18cd1a
commit c795389aae
4 changed files with 89 additions and 2 deletions

View File

@ -351,8 +351,16 @@ impl<R> LaunchContextWith<Attached<WithConfigs, R>> {
}
/// Returns the configured [`PruneConfig`]
/// Any configuration set in CLI will take precedence over those set in toml
pub fn prune_config(&self) -> Option<PruneConfig> {
self.toml_config().prune.clone().or_else(|| self.node_config().prune_config())
let Some(mut node_prune_config) = self.node_config().prune_config() else {
// No CLI config is set, use the toml config.
return self.toml_config().prune.clone();
};
// Otherwise, use the CLI configuration and merge with toml config.
node_prune_config.merge(self.toml_config().prune.clone());
Some(node_prune_config)
}
/// Returns the configured [`PruneModes`], returning the default if no config was available.