@@ -10,17 +10,26 @@ import (
1010
1111// Default parameter values for the Params struct.
1212var (
13+ DefaultActiveDuration = 1 * time .Minute // Default active duration
14+ DefaultInactivePendingDuration = 1 * time .Minute // Default inactive pending duration
1315 DefaultMaxGigabytes int64 = 10 // Default maximum allowed gigabytes
1416 DefaultMinGigabytes int64 = 1 // Default minimum allowed gigabytes
1517 DefaultMaxHours int64 = 10 // Default maximum allowed hours
1618 DefaultMinHours int64 = 1 // Default minimum allowed hours
1719 DefaultProofVerificationEnabled = false // Default proof verification flag
1820 DefaultStakingShare = math .LegacyMustNewDecFromStr ("0.1" ) // Default staking share: 0.1
19- DefaultStatusChangeDelay = 1 * time .Minute // Default delay before validator status change
2021)
2122
2223// Validate checks whether the Params fields are valid according to defined rules.
2324func (m * Params ) Validate () error {
25+ if err := validateActiveDuration (m .ActiveDuration ); err != nil {
26+ return fmt .Errorf ("invalid active_duration: %w" , err )
27+ }
28+
29+ if err := validateInactivePendingDuration (m .InactivePendingDuration ); err != nil {
30+ return fmt .Errorf ("invalid inactive_pending_duration: %w" , err )
31+ }
32+
2433 if err := validateMaxGigabytes (m .MaxGigabytes ); err != nil {
2534 return fmt .Errorf ("invalid max_gigabytes: %w" , err )
2635 }
@@ -45,42 +54,66 @@ func (m *Params) Validate() error {
4554 return fmt .Errorf ("invalid staking_share: %w" , err )
4655 }
4756
48- if err := validateStatusChangeDelay (m .StatusChangeDelay ); err != nil {
49- return fmt .Errorf ("invalid status_change_delay: %w" , err )
50- }
51-
5257 return nil
5358}
5459
5560// NewParams creates a new Params instance with custom values.
5661func NewParams (
57- maxGigabytes , minGigabytes , maxHours , minHours int64 , proofVerificationEnabled bool , stakingShare math. LegacyDec ,
58- statusChangeDelay time. Duration ,
62+ activeDuration , inactivePendingDuration time. Duration , maxGigabytes , minGigabytes , maxHours , minHours int64 ,
63+ proofVerificationEnabled bool , stakingShare math. LegacyDec ,
5964) Params {
6065 return Params {
66+ ActiveDuration : activeDuration ,
67+ InactivePendingDuration : inactivePendingDuration ,
6168 MaxGigabytes : maxGigabytes ,
6269 MinGigabytes : minGigabytes ,
6370 MaxHours : maxHours ,
6471 MinHours : minHours ,
6572 ProofVerificationEnabled : proofVerificationEnabled ,
6673 StakingShare : stakingShare ,
67- StatusChangeDelay : statusChangeDelay ,
6874 }
6975}
7076
7177// DefaultParams returns a Params struct initialized with default values.
7278func DefaultParams () Params {
7379 return NewParams (
80+ DefaultActiveDuration ,
81+ DefaultInactivePendingDuration ,
7482 DefaultMaxGigabytes ,
7583 DefaultMinGigabytes ,
7684 DefaultMaxHours ,
7785 DefaultMinHours ,
7886 DefaultProofVerificationEnabled ,
7987 DefaultStakingShare ,
80- DefaultStatusChangeDelay ,
8188 )
8289}
8390
91+ // validateActiveDuration ensures the activeDuration is positive and non-zero.
92+ func validateActiveDuration (v time.Duration ) error {
93+ if v == 0 {
94+ return errors .New ("value cannot be zero" )
95+ }
96+
97+ if v < 0 {
98+ return errors .New ("value cannot be negative" )
99+ }
100+
101+ return nil
102+ }
103+
104+ // validateInactivePendingDuration ensures the inactivePendingDuration is positive and non-zero.
105+ func validateInactivePendingDuration (v time.Duration ) error {
106+ if v == 0 {
107+ return errors .New ("value cannot be zero" )
108+ }
109+
110+ if v < 0 {
111+ return errors .New ("value cannot be negative" )
112+ }
113+
114+ return nil
115+ }
116+
84117// validateMaxGigabytes ensures maxGigabytes is a positive non-zero integer.
85118func validateMaxGigabytes (v int64 ) error {
86119 if v == 0 {
@@ -155,16 +188,3 @@ func validateStakingShare(v math.LegacyDec) error {
155188
156189 return nil
157190}
158-
159- // validateStatusChangeDelay ensures the delay is positive and non-zero.
160- func validateStatusChangeDelay (v time.Duration ) error {
161- if v == 0 {
162- return errors .New ("value cannot be zero" )
163- }
164-
165- if v < 0 {
166- return errors .New ("value cannot be negative" )
167- }
168-
169- return nil
170- }
0 commit comments