Skip to content

Commit 961b3f7

Browse files
committed
add parameters validation
1 parent 2996d98 commit 961b3f7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/config/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,20 @@ func (c *Config) Validate() error {
313313
c.Node.LazyBlockInterval.Duration, c.Node.BlockTime.Duration)
314314
}
315315

316+
// Validate pruning configuration
317+
if c.Node.PruningEnabled {
318+
// When pruning is enabled, pruning_interval must be >= 1
319+
if c.Node.PruningInterval == 0 {
320+
return fmt.Errorf("pruning_interval must be >= 1 when pruning is enabled")
321+
}
322+
323+
// When pruning is enabled, keeping 0 blocks is contradictory; use pruning_enabled=false
324+
// for archive mode instead.
325+
if c.Node.PruningKeepRecent == 0 {
326+
return fmt.Errorf("pruning_keep_recent must be > 0 when pruning is enabled; use pruning_enabled=false to keep all blocks")
327+
}
328+
}
329+
316330
return nil
317331
}
318332

0 commit comments

Comments
 (0)