@@ -12,9 +12,6 @@ import (
1212)
1313
1414var (
15- // DefaultActiveDuration defines the default duration a node remains active after registration.
16- DefaultActiveDuration = 30 * time .Second
17-
1815 // DefaultDeposit defines the default amount of deposit required for a node.
1916 DefaultDeposit = sdk .NewCoin (sdk .DefaultBondDenom , sdkmath .NewInt (10 ))
2017
3532 QuoteValue : sdkmath .NewInt (10 ),
3633 },
3734 }
35+
36+ // DefaultStatusTimeout defines the default duration before a status is considered outdated.
37+ DefaultStatusTimeout = 30 * time .Second
3838)
3939
4040// GetMinGigabytePrices returns the minimum gigabyte prices configured in the parameters.
@@ -49,10 +49,6 @@ func (m *Params) GetMinHourlyPrices() v1base.Prices {
4949
5050// Validate validates all parameters to ensure they conform to expected rules.
5151func (m * Params ) Validate () error {
52- if err := validateActiveDuration (m .ActiveDuration ); err != nil {
53- return fmt .Errorf ("invalid active_duration: %w" , err )
54- }
55-
5652 if err := validateDeposit (m .Deposit ); err != nil {
5753 return fmt .Errorf ("invalid deposit: %w" , err )
5854 }
@@ -65,44 +61,35 @@ func (m *Params) Validate() error {
6561 return fmt .Errorf ("invalid min_hourly_prices: %w" , err )
6662 }
6763
64+ if err := validateStatusTimeout (m .StatusTimeout ); err != nil {
65+ return fmt .Errorf ("invalid status_timeout: %w" , err )
66+ }
67+
6868 return nil
6969}
7070
7171// NewParams creates a new Params instance with the provided values.
7272func NewParams (
73- activeDuration time. Duration , deposit sdk.Coin , minGigabytePrices , minHourlyPrices v1base.Prices ,
73+ deposit sdk.Coin , minGigabytePrices , minHourlyPrices v1base.Prices , statusTimeout time. Duration ,
7474) Params {
7575 return Params {
76- ActiveDuration : activeDuration ,
7776 Deposit : deposit ,
7877 MinGigabytePrices : minGigabytePrices ,
7978 MinHourlyPrices : minHourlyPrices ,
79+ StatusTimeout : statusTimeout ,
8080 }
8181}
8282
8383// DefaultParams returns the default parameters for the module.
8484func DefaultParams () Params {
8585 return NewParams (
86- DefaultActiveDuration ,
8786 DefaultDeposit ,
8887 DefaultMinGigabytePrices ,
8988 DefaultMinHourlyPrices ,
89+ DefaultStatusTimeout ,
9090 )
9191}
9292
93- // validateActiveDuration checks that the active duration is greater than zero.
94- func validateActiveDuration (v time.Duration ) error {
95- if v == 0 {
96- return errors .New ("value cannot be zero" )
97- }
98-
99- if v < 0 {
100- return errors .New ("value cannot be negative" )
101- }
102-
103- return nil
104- }
105-
10693// validateDeposit checks that the deposit is not nil, not negative, and valid.
10794func validateDeposit (v sdk.Coin ) error {
10895 if v .IsNil () {
@@ -145,3 +132,16 @@ func validateMinHourlyPrices(v []v1base.Price) error {
145132
146133 return nil
147134}
135+
136+ // validateStatusTimeout checks that the status duration is greater than zero.
137+ func validateStatusTimeout (v time.Duration ) error {
138+ if v == 0 {
139+ return errors .New ("value cannot be zero" )
140+ }
141+
142+ if v < 0 {
143+ return errors .New ("value cannot be negative" )
144+ }
145+
146+ return nil
147+ }
0 commit comments