Skip to content

Commit

Permalink
Merge pull request #3403 from autonomys/pruning-refactor
Browse files Browse the repository at this point in the history
Refactor ensure_pruning_params variable names
  • Loading branch information
teor2345 authored Feb 24, 2025
2 parents ab4c784 + e486c53 commit 784e5c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/subspace-node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn get_genesis_allocations(contents: &str) -> Vec<(AccountId, Balance)> {

pub fn mainnet_compiled() -> Result<GenericChainSpec, String> {
Ok(GenericChainSpec::builder(
WASM_BINARY.ok_or_else(|| "Wasm binary must be built for Taurus".to_string())?,
WASM_BINARY.ok_or_else(|| "Wasm binary must be built for Mainnet".to_string())?,
None,
)
.with_name("Autonomys Mainnet")
Expand Down
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 784e5c1

Please sign in to comment.