-
Notifications
You must be signed in to change notification settings - Fork 51
/
keys.go
152 lines (124 loc) · 4.04 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package types
import (
"encoding/binary"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName is the name of this module.
ModuleName = "shield"
// RouterKey is used to route messages.
RouterKey = ModuleName
// StoreKey is the prefix under which we store this module's data.
StoreKey = ModuleName
// QuerierRoute is used to handle abci_query requests.
QuerierRoute = ModuleName
// DefaultParamspace is the default name for parameter store.
DefaultParamspace = ModuleName
)
var (
ShieldAdminKey = []byte{0x00}
TotalCollateralKey = []byte{0x01}
TotalWithdrawingKey = []byte{0x02}
TotalShieldKey = []byte{0x03}
TotalClaimedKey = []byte{0x04}
ServiceFeesKey = []byte{0x05}
RemainingServiceFeesKey = []byte{0x06}
PoolKey = []byte{0x07}
NextPoolIDKey = []byte{0x08}
NextPurchaseIDKey = []byte{0x09}
PurchaseListKey = []byte{0x0A}
PurchaseQueueKey = []byte{0x0B}
ProviderKey = []byte{0x0C}
WithdrawQueueKey = []byte{0x0D}
LastUpdateTimeKey = []byte{0x0E}
GlobalStakeForShieldPoolKey = []byte{0x0F}
StakeForShieldKey = []byte{0x11}
BlockServiceFeesKey = []byte{0x12}
OriginalStakingKey = []byte{0x13}
ReimbursementKey = []byte{0x14}
)
func GetTotalCollateralKey() []byte {
return TotalCollateralKey
}
func GetTotalWithdrawingKey() []byte {
return TotalWithdrawingKey
}
func GetTotalShieldKey() []byte {
return TotalShieldKey
}
func GetTotalClaimedKey() []byte {
return TotalClaimedKey
}
func GetServiceFeesKey() []byte {
return ServiceFeesKey
}
func GetBlockServiceFeesKey() []byte {
return BlockServiceFeesKey
}
func GetRemainingServiceFeesKey() []byte {
return RemainingServiceFeesKey
}
// GetPoolKey gets the key for the pool identified by pool ID.
func GetPoolKey(id uint64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, id)
return append(PoolKey, b...)
}
// GetShieldAdminKey gets the key for the shield admin.
func GetShieldAdminKey() []byte {
return ShieldAdminKey
}
// GetNextPoolIDKey gets the key for the next pool ID.
func GetNextPoolIDKey() []byte {
return NextPoolIDKey
}
// GetNextPurchaseIDKey gets the key for the next pool ID.
func GetNextPurchaseIDKey() []byte {
return NextPurchaseIDKey
}
// GetPurchaseTxHashKey gets the key for a purchase.
func GetPurchaseListKey(id uint64, purchaser sdk.AccAddress) []byte {
bz := make([]byte, 8)
binary.LittleEndian.PutUint64(bz, id)
return append(PurchaseListKey, append(bz, purchaser.Bytes()...)...)
}
// GetProviderKey gets the key for the delegator's tracker.
func GetProviderKey(addr sdk.AccAddress) []byte {
return append(ProviderKey, addr...)
}
// GetWithdrawCompletionTimeKey gets a withdraw queue key,
// which is obtained from the completion time.
func GetWithdrawCompletionTimeKey(timestamp time.Time) []byte {
bz := sdk.FormatTimeBytes(timestamp)
return append(WithdrawQueueKey, bz...)
}
// GetPurchaseExpirationTimeKey gets a withdraw queue key,
// which is obtained from the expiration time.
func GetPurchaseExpirationTimeKey(timestamp time.Time) []byte {
bz := sdk.FormatTimeBytes(timestamp)
return append(PurchaseQueueKey, bz...)
}
// GetLastUpdateTimeKey gets the key for the last update time.
func GetLastUpdateTimeKey() []byte {
return LastUpdateTimeKey
}
func GetGlobalStakeForShieldPoolKey() []byte {
return GlobalStakeForShieldPoolKey
}
func GetStakeForShieldKey(poolID uint64, purchaser sdk.AccAddress) []byte {
bz := make([]byte, 8)
binary.LittleEndian.PutUint64(bz, poolID)
return append(StakeForShieldKey, append(bz, purchaser...)...)
}
func GetOriginalStakingKey(purchaseID uint64) []byte {
bz := make([]byte, 8)
binary.LittleEndian.PutUint64(bz, purchaseID)
return append(OriginalStakingKey, bz...)
}
// GetReimbursementKey gets the key for a reimbursement.
func GetReimbursementKey(proposalID uint64) []byte {
bz := make([]byte, 8)
binary.LittleEndian.PutUint64(bz, proposalID)
return append(ReimbursementKey, bz...)
}