-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
48 lines (39 loc) · 1.06 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
40
41
42
43
44
45
46
47
48
package types
import (
"fmt"
"time"
"github.com/fastock/fastock-chain/x/evidence/exported"
)
// DONTCOVER
// GenesisState defines the evidence module's genesis state.
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
Evidence []exported.Evidence `json:"evidence" yaml:"evidence"`
}
func NewGenesisState(p Params, e []exported.Evidence) GenesisState {
return GenesisState{
Params: p,
Evidence: e,
}
}
// DefaultGenesisState returns the evidence module's default genesis state.
func DefaultGenesisState() GenesisState {
return GenesisState{
Params: DefaultParams(),
Evidence: []exported.Evidence{},
}
}
// Validate performs basic gensis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
for _, e := range gs.Evidence {
if err := e.ValidateBasic(); err != nil {
return err
}
}
maxEvidence := gs.Params.MaxEvidenceAge
if maxEvidence < 1*time.Minute {
return fmt.Errorf("max evidence age must be at least 1 minute, is %s", maxEvidence.String())
}
return nil
}