-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add proposal for modify the MaxGasUsedPerBlock (#3241)
* add proposal for modify the MaxGasUsedPerBlock * modify the issue
- Loading branch information
Showing
14 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
sdk "github.com/okex/exchain/libs/cosmos-sdk/types" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/params/subspace" | ||
) | ||
|
||
const ( | ||
QueryBlockConfig = "blockconfig" | ||
MaxGasUsedPerBlock = "MaxGasUsedPerBlock" | ||
) | ||
|
||
// BlockConfig is the struct of the parameters in this module | ||
type BlockConfig struct { | ||
MaxGasUsedPerBlock int64 `json:"maxGasUsedPerBlock"` | ||
} | ||
|
||
func NewDefaultBlockConfig() *BlockConfig { | ||
return &BlockConfig{ | ||
MaxGasUsedPerBlock: sdk.DefaultMaxGasUsedPerBlock, | ||
} | ||
} | ||
|
||
func (p BlockConfig) String() string { | ||
return fmt.Sprintf(` | ||
MaxGasUsedPerBlock: %d, | ||
`, p.MaxGasUsedPerBlock) | ||
} | ||
|
||
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs | ||
// pairs of auth module's parameters. | ||
// nolint | ||
func (p *BlockConfig) ParamSetPairs() subspace.ParamSetPairs { | ||
return subspace.ParamSetPairs{ | ||
{[]byte(MaxGasUsedPerBlock), &p.MaxGasUsedPerBlock, ValidateInt64("maxGasUsedPerBlock")}, | ||
} | ||
} | ||
|
||
func ValidateInt64(param string) subspace.ValueValidatorFn { | ||
return func(i interface{}) error { | ||
v, ok := i.(int64) | ||
if !ok { | ||
return fmt.Errorf("invalid parameter type: %T", i) | ||
} | ||
|
||
if v < -1 { | ||
return fmt.Errorf("%s must be equal or greater than -1: %d", param, v) | ||
} | ||
|
||
return nil | ||
} | ||
} |