Skip to content

Commit

Permalink
fix: validation of node price parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ironman0x7b2 committed Nov 30, 2024
1 parent e467630 commit dc9c9e4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions x/node/types/v3/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
var (
DefaultDeposit = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10))
DefaultActiveDuration = 30 * time.Second
DefaultMinGigabytePrices = sdk.NewDecCoins(sdk.NewDecCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)))
DefaultMinHourlyPrices = sdk.NewDecCoins(sdk.NewDecCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1)))
DefaultMinGigabytePrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdkmath.LegacyMustNewDecFromStr("0.1")))
DefaultMinHourlyPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdkmath.LegacyMustNewDecFromStr("0.1")))
DefaultMaxSessionGigabytes int64 = 10
DefaultMinSessionGigabytes int64 = 1
DefaultMaxSessionHours int64 = 10
Expand Down Expand Up @@ -190,17 +190,14 @@ func validateActiveDuration(v interface{}) error {
}

func validateMinGigabytePrices(v interface{}) error {
value, ok := v.(sdk.Coins)
value, ok := v.(sdk.DecCoins)
if !ok {
return fmt.Errorf("invalid parameter type %T", v)
}

if value == nil {
return nil
}
if value.IsAnyNil() {
return fmt.Errorf("min_gigabyte_prices cannot contain nil")
}
if !value.IsValid() {
return fmt.Errorf("min_gigabyte_prices must be valid")
}
Expand All @@ -209,17 +206,14 @@ func validateMinGigabytePrices(v interface{}) error {
}

func validateMinHourlyPrices(v interface{}) error {
value, ok := v.(sdk.Coins)
value, ok := v.(sdk.DecCoins)
if !ok {
return fmt.Errorf("invalid parameter type %T", v)
}

if value == nil {
return nil
}
if value.IsAnyNil() {
return fmt.Errorf("min_hourly_prices cannot contain nil")
}
if !value.IsValid() {
return fmt.Errorf("min_hourly_prices must be valid")
}
Expand Down

0 comments on commit dc9c9e4

Please sign in to comment.