-
Notifications
You must be signed in to change notification settings - Fork 182
/
keys.go
63 lines (52 loc) · 2.05 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
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
const (
// ModuleName is the module name constant used in many places
ModuleName = "distribution"
// StoreKey is the store key string for distribution
StoreKey = ModuleName
// RouterKey is the message route for distribution
RouterKey = ModuleName
// QuerierRoute is the querier route for distribution
QuerierRoute = ModuleName
// ShortUseByCli added for okexchaincli
ShortUseByCli = "distr"
)
// Keys for distribution store
// Items are stored with the following key: values
//
// - 0x01: sdk.ConsAddress
//
// - 0x03<accAddr_Bytes>: sdk.AccAddress
//
// - 0x07<valAddr_Bytes>: ValidatorCurrentRewards
var (
FeePoolKey = []byte{0x00} // key for global distribution state
ProposerKey = []byte{0x01} // key for the proposer operator address
DelegatorWithdrawAddrPrefix = []byte{0x03} // key for delegator withdraw address
ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission
)
// GetDelegatorWithdrawInfoAddress returns an address from a delegator's withdraw info key
func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) {
addr := key[1:]
if len(addr) != sdk.AddrLen {
panic("unexpected key length")
}
return sdk.AccAddress(addr)
}
//GetValidatorAccumulatedCommissionAddress returns the address from a validator's accumulated commission key
func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) {
addr := key[1:]
if len(addr) != sdk.AddrLen {
panic("unexpected key length")
}
return sdk.ValAddress(addr)
}
// GetDelegatorWithdrawAddrKey returns the key for a delegator's withdraw addr
func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte {
return append(DelegatorWithdrawAddrPrefix, delAddr.Bytes()...)
}
// GetValidatorAccumulatedCommissionKey returns the key for a validator's current commission
func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte {
return append(ValidatorAccumulatedCommissionPrefix, v.Bytes()...)
}