-
Notifications
You must be signed in to change notification settings - Fork 30
/
genesis.go
49 lines (45 loc) · 1.84 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
49
package types
import (
sdk "github.com/Finschia/finschia-sdk/types"
)
//nolint:interfacer
func NewGenesisState(
params Params, fp FeePool, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, r []ValidatorOutstandingRewardsRecord,
acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord,
cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord,
) *GenesisState {
return &GenesisState{
Params: params,
FeePool: fp,
DelegatorWithdrawInfos: dwis,
PreviousProposer: pp.String(),
OutstandingRewards: r,
ValidatorAccumulatedCommissions: acc,
ValidatorHistoricalRewards: historical,
ValidatorCurrentRewards: cur,
DelegatorStartingInfos: dels,
ValidatorSlashEvents: slashes,
}
}
// get raw genesis raw message for testing
func DefaultGenesisState() *GenesisState {
return &GenesisState{
FeePool: InitialFeePool(),
Params: DefaultParams(),
DelegatorWithdrawInfos: []DelegatorWithdrawInfo{},
PreviousProposer: "",
OutstandingRewards: []ValidatorOutstandingRewardsRecord{},
ValidatorAccumulatedCommissions: []ValidatorAccumulatedCommissionRecord{},
ValidatorHistoricalRewards: []ValidatorHistoricalRewardsRecord{},
ValidatorCurrentRewards: []ValidatorCurrentRewardsRecord{},
DelegatorStartingInfos: []DelegatorStartingInfoRecord{},
ValidatorSlashEvents: []ValidatorSlashEventRecord{},
}
}
// ValidateGenesis validates the genesis state of distribution genesis input
func ValidateGenesis(gs *GenesisState) error {
if err := gs.Params.ValidateBasic(); err != nil {
return err
}
return gs.FeePool.ValidateGenesis()
}