-
Notifications
You must be signed in to change notification settings - Fork 16
/
keys.go
96 lines (70 loc) · 2.83 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
package types
import (
"github.com/KYVENetwork/chain/util"
)
const (
// ModuleName defines the module name
ModuleName = "delegation"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey defines the module's message routing key
RouterKey = ModuleName
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_delegation"
)
var ParamsKey = []byte{0x00}
var StakerIndexKeyPrefix = []byte{1} // StakerIndexPoolCountKeyPrefix = []byte{1}
var (
// DelegatorKeyPrefix is the prefix to retrieve all Delegator entries
DelegatorKeyPrefix = []byte{1, 0}
// DelegatorKeyPrefixIndex2 is the prefix for a different key order for the DelegatorKeyPrefix
DelegatorKeyPrefixIndex2 = []byte{1, 1}
// DelegationEntriesKeyPrefix is the prefix to retrieve all DelegationEntries
DelegationEntriesKeyPrefix = []byte{2}
// DelegationDataKeyPrefix ...
DelegationDataKeyPrefix = []byte{3}
// DelegationSlashEntriesKeyPrefix ...
DelegationSlashEntriesKeyPrefix = []byte{4}
// QueueKey ...
QueueKey = []byte{5}
// UndelegationQueueKeyPrefix ...
UndelegationQueueKeyPrefix = []byte{6, 0}
// UndelegationQueueKeyPrefixIndex2 ...
UndelegationQueueKeyPrefixIndex2 = []byte{6, 1}
// RedelegationCooldownPrefix ...
RedelegationCooldownPrefix = []byte{7}
)
// DelegatorKey returns the store Key to retrieve a Delegator from the index fields
func DelegatorKey(stakerAddress string, delegatorAddress string) []byte {
return util.GetByteKey(stakerAddress, delegatorAddress)
}
// DelegatorKeyIndex2 returns the store Key to retrieve a Delegator from the index fields
func DelegatorKeyIndex2(delegatorAddress string, stakerAddress string) []byte {
return util.GetByteKey(delegatorAddress, stakerAddress)
}
// DelegationEntriesKey returns the store Key to retrieve a DelegationEntries from the index fields
func DelegationEntriesKey(stakerAddress string, kIndex uint64) []byte {
return util.GetByteKey(stakerAddress, kIndex)
}
// DelegationDataKey returns the store Key to retrieve a DelegationPoolData from the index fields
func DelegationDataKey(stakerAddress string) []byte {
return util.GetByteKey(stakerAddress)
}
func UndelegationQueueKey(kIndex uint64) []byte {
return util.GetByteKey(kIndex)
}
func UndelegationQueueKeyIndex2(stakerAddress string, kIndex uint64) []byte {
return util.GetByteKey(stakerAddress, kIndex)
}
func RedelegationCooldownKey(delegator string, block uint64) []byte {
return util.GetByteKey(delegator, block)
}
func DelegationSlashEntriesKey(stakerAddress string, kIndex uint64) []byte {
return util.GetByteKey(stakerAddress, kIndex)
}
func StakerIndexKey(amount uint64, stakerAddress string) []byte {
return util.GetByteKey(amount, stakerAddress)
}
//func StakerIndexByPoolCountKey(poolCount uint64, amount uint64, stakerAddress string) []byte {
// return util.GetByteKey(poolCount, amount, stakerAddress)
//}