/
genesis.go
111 lines (100 loc) · 3.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package config
import (
"math/big"
"github.com/koinotice/vite/common/types"
)
type Genesis struct {
GenesisAccountAddress *types.Address
ForkPoints *ForkPoints
ConsensusGroupInfo *ConsensusGroupContractInfo
MintageInfo *MintageContractInfo
PledgeInfo *PledgeContractInfo
AccountBalanceMap map[string]map[string]*big.Int // address - tokenId - balanceAmount
}
func IsCompleteGenesisConfig(genesisConfig *Genesis) bool {
if genesisConfig == nil || genesisConfig.GenesisAccountAddress == nil ||
genesisConfig.ConsensusGroupInfo == nil || len(genesisConfig.ConsensusGroupInfo.ConsensusGroupInfoMap) == 0 ||
len(genesisConfig.ConsensusGroupInfo.RegistrationInfoMap) == 0 ||
genesisConfig.MintageInfo == nil || len(genesisConfig.MintageInfo.TokenInfoMap) == 0 ||
len(genesisConfig.AccountBalanceMap) == 0 {
return false
}
return true
}
type ForkPoint struct {
Height uint64
Version uint32
}
type ForkPoints struct {
SeedFork *ForkPoint
DexFork *ForkPoint
}
type GenesisVmLog struct {
Data string
Topics []types.Hash
}
type ConsensusGroupContractInfo struct {
ConsensusGroupInfoMap map[string]ConsensusGroupInfo // consensus group info, gid - info
RegistrationInfoMap map[string]map[string]RegistrationInfo // registration info, gid - nodeName - info
HisNameMap map[string]map[string]string // used node name for node addr, gid - nodeAddr - nodeName
VoteStatusMap map[string]map[string]string // vote info, gid - voteAddr - nodeName
}
type MintageContractInfo struct {
TokenInfoMap map[string]TokenInfo // tokenId - info
LogList []GenesisVmLog // mint events
}
type PledgeContractInfo struct {
PledgeInfoMap map[string][]PledgeInfo
PledgeBeneficialMap map[string]*big.Int
}
type ConsensusGroupInfo struct {
NodeCount uint8
Interval int64
PerCount int64
RandCount uint8
RandRank uint8
Repeat uint16
CheckLevel uint8
CountingTokenId types.TokenTypeId
RegisterConditionId uint8
RegisterConditionParam RegisterConditionParam
VoteConditionId uint8
VoteConditionParam VoteConditionParam
Owner types.Address
PledgeAmount *big.Int
WithdrawHeight uint64
}
type RegisterConditionParam struct {
PledgeAmount *big.Int
PledgeToken types.TokenTypeId
PledgeHeight uint64
}
type VoteConditionParam struct {
}
type RegistrationInfo struct {
NodeAddr types.Address
PledgeAddr types.Address
Amount *big.Int
WithdrawHeight uint64
RewardTime int64
CancelTime int64
HisAddrList []types.Address
}
type TokenInfo struct {
TokenName string
TokenSymbol string
TotalSupply *big.Int
Decimals uint8
Owner types.Address
PledgeAmount *big.Int
PledgeAddr types.Address
WithdrawHeight uint64
MaxSupply *big.Int
OwnerBurnOnly bool
IsReIssuable bool
}
type PledgeInfo struct {
Amount *big.Int
WithdrawHeight uint64
BeneficialAddr types.Address
}