forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
107 lines (90 loc) · 3.95 KB
/
types.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
package stake
//// GenesisState - all staking state that must be provided at genesis
//type GenesisState struct {
//Pool Pool `json:"pool"`
//Params Params `json:"params"`
//}
//func NewGenesisState(pool Pool, params Params, candidates []Candidate, bonds []Delegation) GenesisState {
//return GenesisState{
//Pool: pool,
//Params: params,
//}
//}
//// get raw genesis raw message for testing
//func DefaultGenesisState() GenesisState {
//return GenesisState{
//Pool: initialPool(),
//Params: defaultParams(),
//}
//}
//// fee information for a validator
//type Validator struct {
//Adjustments []sdk.Rat `json:"fee_adjustments"` // XXX Adjustment factors for lazy fee accounting, couples with Params.BondDenoms
//PrevBondedShares sdk.Rat `json:"prev_bonded_shares"` // total shares of a global hold pools
//}
////_________________________________________________________________________
//// Params defines the high level settings for staking
//type Params struct {
//FeeDenoms []string `json:"fee_denoms"` // accepted fee denoms
//ReservePoolFee sdk.Rat `json:"reserve_pool_fee"` // percent of fees which go to reserve pool
//}
//func (p Params) equal(p2 Params) bool {
//return p.BondDenom == p2.BondDenom &&
//p.ReservePoolFee.Equal(p2.ReservePoolFee)
//}
//func defaultParams() Params {
//return Params{
//FeeDenoms: []string{"steak"},
//ReservePoolFee: sdk.NewRat(5, 100),
//}
//}
////_________________________________________________________________________
//// Pool - dynamic parameters of the current state
//type Pool struct {
//FeeReservePool sdk.Coins `json:"fee_reserve_pool"` // XXX reserve pool of collected fees for use by governance
//FeePool sdk.Coins `json:"fee_pool"` // XXX fee pool for all the fee shares which have already been distributed
//FeeSumReceived sdk.Coins `json:"fee_sum_received"` // XXX sum of all fees received, post reserve pool `json:"fee_sum_received"`
//FeeRecent sdk.Coins `json:"fee_recent"` // XXX most recent fee collected
//FeeAdjustments []sdk.Rat `json:"fee_adjustments"` // XXX Adjustment factors for lazy fee accounting, couples with Params.BondDenoms
//PrevBondedShares sdk.Rat `json:"prev_bonded_shares"` // XXX last recorded bonded shares
//}
//func (p Pool) equal(p2 Pool) bool {
//return p.FeeReservePool.IsEqual(p2.FeeReservePool) &&
//p.FeePool.IsEqual(p2.FeePool) &&
//p.FeeSumReceived.IsEqual(p2.FeeSumReceived) &&
//p.FeeRecent.IsEqual(p2.FeeRecent) &&
//sdk.RatsEqual(p.FeeAdjustments, p2.FeeAdjustments) &&
//p.PrevBondedShares.Equal(p2.PrevBondedShares)
//}
//// initial pool for testing
//func initialPool() Pool {
//return Pool{
//FeeReservePool: sdk.Coins(nil),
//FeePool: sdk.Coins(nil),
//FeeSumReceived: sdk.Coins(nil),
//FeeRecent: sdk.Coins(nil),
//FeeAdjustments: []sdk.Rat{sdk.ZeroRat()},
//PrevBondedShares: sdk.ZeroRat(),
//}
//}
////_________________________________________________________________________
//// Used in calculation of fee shares, added to a queue for each block where a power change occures
//type PowerChange struct {
//Height int64 `json:"height"` // block height at change
//Power sdk.Rat `json:"power"` // total power at change
//PrevPower sdk.Rat `json:"prev_power"` // total power at previous height-1
//FeesIn sdk.Coins `json:"fees_in"` // fees in at block height
//PrevFeePool sdk.Coins `json:"prev_fee_pool"` // total fees in at previous block height
//}
////_________________________________________________________________________
//// KEY MANAGEMENT
//var (
//// Keys for store prefixes
//PowerChangeKey = []byte{0x09} // prefix for power change object
//)
//// get the key for the accumulated update validators
//func GetPowerChangeKey(height int64) []byte {
//heightBytes := make([]byte, binary.MaxVarintLen64)
//binary.BigEndian.PutUint64(heightBytes, ^uint64(height)) // invert height (older validators first)
//return append(PowerChangeKey, heightBytes...)
//}