forked from crescent-network/crescent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
30 lines (25 loc) · 801 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
package types
import (
"fmt"
"time"
utils "github.com/crescent-network/crescent/v5/types"
)
// NewGenesisState creates a new GenesisState object
func NewGenesisState(params Params, lastBlockTime *time.Time) *GenesisState {
return &GenesisState{
LastBlockTime: lastBlockTime,
Params: params,
}
}
// DefaultGenesisState creates a default GenesisState object
func DefaultGenesisState() *GenesisState {
return NewGenesisState(DefaultParams(), nil)
}
// ValidateGenesis validates the provided genesis state to ensure the
// expected invariants holds.
func ValidateGenesis(data GenesisState) error {
if data.LastBlockTime != nil && data.LastBlockTime.Before(utils.ParseTime("0001-01-01T00:00:00Z")) {
return fmt.Errorf("invalid last block time")
}
return data.Params.Validate()
}