-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenesis.go
31 lines (27 loc) · 814 Bytes
/
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
package checkers
// NewGenesisState creates a new genesis state with default values.
func NewGenesisState() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
}
}
// Validate performs basic genesis state validation returning an error upon any
func (gs *GenesisState) Validate() error {
if err := gs.Params.Validate(); err != nil {
return err
}
unique := make(map[string]bool)
for _, indexedStoredGame := range gs.IndexedStoredGameList {
if length := len([]byte(indexedStoredGame.Index)); MaxIndexLength < length || length < 1 {
return ErrIndexTooLong
}
if _, ok := unique[indexedStoredGame.Index]; ok {
return ErrDuplicateAddress
}
if err := indexedStoredGame.StoredGame.Validate(); err != nil {
return err
}
unique[indexedStoredGame.Index] = true
}
return nil
}