/
keys.go
138 lines (106 loc) · 4.23 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
138
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
const (
// ModuleName defines the module name
ModuleName = "gauge"
// 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_gauge"
GaugePoolName = ModuleName
BribePoolName = "bribe"
)
const (
prefixGaugeDenom = iota + 1
prefixBribeDenom
prefixTotalDepositedAmount
prefixDepositedAmountByUser
prefixTotalDerivedAmount
prefixDerivedAmountByUser
prefixReward
prefixUserReward
prefixUserVeIDByAddress
prefixEpoch
prefixPointHistoryByEpoch
prefixUserEpoch
prefixUserPointHistoryByUserEpoch
prefixRewardEpoch
prefixRewardPointHistoryByRewardEpoch
)
var (
KeyPrefixGaugeDenom = []byte{prefixGaugeDenom}
KeyPrefixBribeDenom = []byte{prefixBribeDenom}
KeyPrefixTotalDepositedAmount = []byte{prefixTotalDepositedAmount}
KeyPrefixDepositedAmountByUser = []byte{prefixDepositedAmountByUser}
KeyPrefixTotalDerivedAmount = []byte{prefixTotalDerivedAmount}
KeyPrefixDerivedAmountByUser = []byte{prefixDerivedAmountByUser}
KeyPrefixReward = []byte{prefixReward}
KeyPrefixUserReward = []byte{prefixUserReward}
KeyPrefixUserVeIDByAddress = []byte{prefixUserVeIDByAddress}
KeyPrefixEpoch = []byte{prefixEpoch}
KeyPrefixPointHistoryByEpoch = []byte{prefixPointHistoryByEpoch}
KeyPrefixUserEpoch = []byte{prefixUserEpoch}
KeyPrefixUserPointHistoryByUserEpoch = []byte{prefixUserPointHistoryByUserEpoch}
KeyPrefixRewardEpoch = []byte{prefixRewardEpoch}
KeyPrefixRewardPointHistoryByRewardEpoch = []byte{prefixRewardPointHistoryByRewardEpoch}
)
func GaugeKey(denom string) []byte {
return append(KeyPrefixGaugeDenom, denom...)
}
func BribeKey(denom string) []byte {
return append(KeyPrefixBribeDenom, denom...)
}
func TotalDepositedAmountKey(gaugeOrBribe []byte) []byte {
return append(KeyPrefixTotalDepositedAmount, gaugeOrBribe...)
}
func DepositedAmountByUserKey(gaugeOrBribe []byte, veID uint64) []byte {
prefix := append(KeyPrefixDepositedAmountByUser, gaugeOrBribe...)
return append(prefix, sdk.Uint64ToBigEndian(veID)...)
}
func TotalDerivedAmountKey(gaugeKey []byte) []byte {
return append(KeyPrefixTotalDerivedAmount, gaugeKey...)
}
func DerivedAmountByUserKey(gaugeKey []byte, veID uint64) []byte {
prefix := append(KeyPrefixDerivedAmountByUser, gaugeKey...)
return append(prefix, sdk.Uint64ToBigEndian(veID)...)
}
func RewardKeyPrefix(gaugeOrBribe []byte) []byte {
return append(KeyPrefixReward, gaugeOrBribe...)
}
func RewardKey(gaugeOrBribe []byte, rewardDenom string) []byte {
return append(RewardKeyPrefix(gaugeOrBribe), rewardDenom...)
}
func UserRewardKey(gaugeOrBribe []byte, rewardDenom string, veID uint64) []byte {
prefix := append(KeyPrefixUserReward, gaugeOrBribe...)
prefix = append(prefix, rewardDenom...)
return append(prefix, sdk.Uint64ToBigEndian(veID)...)
}
func UserVeIDByAddressKey(gaugeKey []byte, acc sdk.AccAddress) []byte {
prefix := append(KeyPrefixUserVeIDByAddress, gaugeKey...)
return append(prefix, acc...)
}
func EpochKey(gaugeOrBribe []byte) []byte {
return append(KeyPrefixEpoch, gaugeOrBribe...)
}
func PointKey(gaugeOrBribe []byte, epoch uint64) []byte {
prefix := append(KeyPrefixPointHistoryByEpoch, gaugeOrBribe...)
return append(prefix, sdk.Uint64ToBigEndian(epoch)...)
}
func UserEpochKey(gaugeOrBribe []byte, veID uint64) []byte {
return append(append(KeyPrefixUserEpoch, gaugeOrBribe...), sdk.Uint64ToBigEndian(veID)...)
}
func UserPointKey(gaugeOrBribe []byte, veID uint64, epoch uint64) []byte {
prefix := append(KeyPrefixUserPointHistoryByUserEpoch, gaugeOrBribe...)
return append(append(prefix, sdk.Uint64ToBigEndian(veID)...), sdk.Uint64ToBigEndian(epoch)...)
}
func RewardEpochKey(gaugeOrBribe []byte, rewardDenom string) []byte {
return append(append(KeyPrefixRewardEpoch, gaugeOrBribe...), rewardDenom...)
}
func RewardPointKey(gaugeOrBribe []byte, rewardDenom string, epoch uint64) []byte {
prefix := append(KeyPrefixRewardPointHistoryByRewardEpoch, gaugeOrBribe...)
return append(append(prefix, rewardDenom...), sdk.Uint64ToBigEndian(epoch)...)
}