/
genesis.go
39 lines (34 loc) · 1.07 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package types
import (
"fmt"
)
// GenesisState - all auth state that must be provided at genesis
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
Accounts Accounts
}
// NewGenesisState - Create a new genesis state
func NewGenesisState(params Params, accounts Accounts) GenesisState {
return GenesisState{
Params: params,
Accounts: accounts,
}
}
// DefaultGenesisState - Return a default genesis state
func DefaultGenesisState() GenesisState {
return NewGenesisState(DefaultParams(), nil)
}
// ValidateGenesis performs basic validation of auth genesis data returning an
// error for any failed validation criteria.
func ValidateGenesis(data GenesisState) error {
if data.Params.TxSigLimit == 0 {
return fmt.Errorf("invalid tx signature limit: %d", data.Params.TxSigLimit)
}
if data.Params.MaxMemoCharacters == 0 {
return fmt.Errorf("invalid max memo characters: %d", data.Params.MaxMemoCharacters)
}
if data.Params.TxSizeCostPerByte == 0 {
return fmt.Errorf("invalid tx size cost per byte: %d", data.Params.TxSizeCostPerByte)
}
return nil
}