/
keys.go
137 lines (105 loc) · 3.9 KB
/
keys.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
const (
// ModuleName defines the module name
ModuleName = "ve"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the message route for slashing
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_ve"
EmissionPoolName = "ve_emission_pool"
DistributionPoolName = "ve_distribution_pool"
)
const (
prefixTotalLockedAmount = iota + 1
prefixLockedAmountByUser
prefixNextVeID
prefixEpoch
prefixPointHistoryByEpoch
prefixUserEpoch
prefixUserPointHistoryByUserEpoch
prefixSlopeChange
prefixAttached
prefixVoted
prefixTotalEmission
prefixEmissionAtLastPeriod
prefixEmissionLastTimestamp
prefixDistributionAccruedLastTimestamp
prefixDistributionTotalAmount
prefixDistributionPerPeriod
prefixDistributionClaimLastTimestampByUser
)
var (
KeyPrefixTotalLockedAmount = []byte{prefixTotalLockedAmount}
KeyPrefixLockedAmountByUser = []byte{prefixLockedAmountByUser}
KeyPrefixNextVeID = []byte{prefixNextVeID}
KeyPrefixEpoch = []byte{prefixEpoch}
KeyPrefixPointHistoryByEpoch = []byte{prefixPointHistoryByEpoch}
KeyPrefixUserEpoch = []byte{prefixUserEpoch}
KeyPrefixUserPointHistoryByUserEpoch = []byte{prefixUserPointHistoryByUserEpoch}
KeyPrefixSlopeChange = []byte{prefixSlopeChange}
KeyPrefixAttached = []byte{prefixAttached}
KeyPrefixVoted = []byte{prefixVoted}
KeyPrefixTotalEmission = []byte{prefixTotalEmission}
KeyPrefixEmissionAtLastPeriod = []byte{prefixEmissionAtLastPeriod}
KeyPrefixEmissionLastTimestamp = []byte{prefixEmissionLastTimestamp}
KeyPrefixDistributionAccruedLastTimestamp = []byte{prefixDistributionAccruedLastTimestamp}
KeyPrefixDistributionTotalAmount = []byte{prefixDistributionTotalAmount}
KeyPrefixDistributionPerPeriod = []byte{prefixDistributionPerPeriod}
KeyPrefixDistributionClaimLastTimestampByUser = []byte{prefixDistributionClaimLastTimestampByUser}
)
func TotalLockedAmountKey() []byte {
return KeyPrefixTotalLockedAmount
}
func LockedAmountByUserKey(veID uint64) []byte {
return append(KeyPrefixLockedAmountByUser, sdk.Uint64ToBigEndian(veID)...)
}
func NextVeIDKey() []byte {
return KeyPrefixNextVeID
}
func EpochKey() []byte {
return KeyPrefixEpoch
}
func PointKey(epoch uint64) []byte {
return append(KeyPrefixPointHistoryByEpoch, sdk.Uint64ToBigEndian(epoch)...)
}
func UserEpochKey(veID uint64) []byte {
return append(KeyPrefixUserEpoch, sdk.Uint64ToBigEndian(veID)...)
}
func UserPointKey(veID uint64, userEpoch uint64) []byte {
return append(append(KeyPrefixUserPointHistoryByUserEpoch, sdk.Uint64ToBigEndian(veID)...), sdk.Uint64ToBigEndian(userEpoch)...)
}
func SlopeChangeKey(timestamp uint64) []byte {
return append(KeyPrefixSlopeChange, sdk.Uint64ToBigEndian(timestamp)...)
}
func AttachedKey(veID uint64) []byte {
return append(KeyPrefixAttached, sdk.Uint64ToBigEndian(veID)...)
}
func VotedKey(veID uint64) []byte {
return append(KeyPrefixVoted, sdk.Uint64ToBigEndian(veID)...)
}
func TotalEmissionKey() []byte {
return KeyPrefixTotalEmission
}
func EmissionAtLastPeriodKey() []byte {
return KeyPrefixEmissionAtLastPeriod
}
func EmissionLastTimestampKey() []byte {
return KeyPrefixEmissionLastTimestamp
}
func DistributionAccruedLastTimestampKey() []byte {
return KeyPrefixDistributionAccruedLastTimestamp
}
func DistributionTotalAmountKey() []byte {
return KeyPrefixDistributionTotalAmount
}
func DistributionPerPeriodKey(timestamp uint64) []byte {
return append(KeyPrefixDistributionPerPeriod, sdk.Uint64ToBigEndian(timestamp)...)
}
func DistributionClaimLastTimestampByUserKey(veID uint64) []byte {
return append(KeyPrefixDistributionClaimLastTimestampByUser, sdk.Uint64ToBigEndian(veID)...)
}