Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed May 14, 2024
1 parent 2aa8093 commit d35ba1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 2 additions & 6 deletions x/feemarket/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ import (

// GetParams returns the total set of fee market parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
defer func() {
if r := recover(); r != nil {
k.Logger(ctx).Error("failed to get params", "error", r)
params = types.DefaultParams()
}
}()
bz := ctx.KVStore(k.storeKey).Get(types.ParamsKey)
if len(bz) == 0 {
k.ss.GetParamSetIfExists(ctx, &params)
// avoid nil pointers when params are not set
params.FillDefaults()
} else {
k.cdc.MustUnmarshal(bz, &params)
}
Expand Down
12 changes: 12 additions & 0 deletions x/feemarket/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ func (p Params) GetBaseFee() *big.Int {
return p.BaseFee.BigInt()
}

func (p *Params) FillDefaults() {
if p.BaseFee.IsNil() {
p.BaseFee = sdkmath.NewIntFromUint64(params.InitialBaseFee)
}
if p.MinGasPrice.IsNil() {
p.MinGasPrice = DefaultMinGasPrice
}
if p.MinGasMultiplier.IsNil() {
p.MinGasMultiplier = DefaultMinGasMultiplier
}
}

func validateMinGasPrice(i interface{}) error {
v, ok := i.(sdkmath.LegacyDec)

Expand Down

0 comments on commit d35ba1b

Please sign in to comment.