Skip to content

Commit

Permalink
Fix confusing variable shadowing in ensure_block_and_state_pruning_pa…
Browse files Browse the repository at this point in the history
…rams
  • Loading branch information
teor2345 committed Feb 24, 2025
1 parent 85e96c8 commit e486c53
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions crates/subspace-node/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,46 +387,46 @@ pub async fn run(run_options: RunOptions) -> Result<(), Error> {
}

pub fn ensure_block_and_state_pruning_params(config: &mut Configuration) {
let blocks_to_prune =
let domains_pruning_depth =
DOMAINS_BLOCK_PRUNING_DEPTH.saturating_mul(DOMAINS_PRUNING_DEPTH_MULTIPLIER);

if let BlocksPruning::Some(blocks) = config.blocks_pruning {
config.blocks_pruning = BlocksPruning::Some(if blocks >= blocks_to_prune {
config.blocks_pruning = BlocksPruning::Some(if blocks >= domains_pruning_depth {
blocks
} else {
warn!(
"Blocks pruning config needs to be at least {:?}",
blocks_to_prune
domains_pruning_depth
);
blocks_to_prune
domains_pruning_depth
});
}

match &config.state_pruning {
None => {
config.state_pruning = Some(PruningMode::Constrained(Constraints {
max_blocks: Some(blocks_to_prune),
max_blocks: Some(domains_pruning_depth),
}))
}
Some(pruning_mode) => {
if let PruningMode::Constrained(constraints) = pruning_mode {
let blocks_to_prune = match constraints.max_blocks {
None => blocks_to_prune,
Some(blocks) => {
if blocks >= blocks_to_prune {
blocks
let max_blocks = match constraints.max_blocks {
None => domains_pruning_depth,
Some(max_blocks) => {
if max_blocks >= domains_pruning_depth {
max_blocks
} else {
warn!(
"State pruning config needs to be at least {:?}",
blocks_to_prune
domains_pruning_depth
);
blocks_to_prune
domains_pruning_depth
}
}
};

config.state_pruning = Some(PruningMode::Constrained(Constraints {
max_blocks: Some(blocks_to_prune),
max_blocks: Some(max_blocks),
}))
}
}
Expand Down

0 comments on commit e486c53

Please sign in to comment.