/
keys.go
61 lines (49 loc) · 2.08 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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)
const (
// ModuleName is the name of the oracle module
ModuleName = "oracle"
// StoreKey is the string store representation
StoreKey = ModuleName
// RouterKey is the msg router key for the oracle module
RouterKey = ModuleName
// QuerierRoute is the query router key for the oracle module
QuerierRoute = ModuleName
)
// KVStore key prefixes
var (
KeyPrefixExchangeRate = []byte{0x01} // prefix for each key to a rate
KeyPrefixFeederDelegation = []byte{0x02} // prefix for each key to a feeder delegation
KeyPrefixMissCounter = []byte{0x03} // prefix for each key to a miss counter
KeyPrefixAggregateExchangeRatePrevote = []byte{0x04} // prefix for each key to a aggregate prevote
KeyPrefixAggregateExchangeRateVote = []byte{0x05} // prefix for each key to a aggregate vote
)
// GetExchangeRateKey - stored by *denom*
func GetExchangeRateKey(denom string) (key []byte) {
key = append(key, KeyPrefixExchangeRate...)
key = append(key, []byte(denom)...)
return append(key, 0) // append 0 for null-termination
}
// GetFeederDelegationKey - stored by *Validator* address
func GetFeederDelegationKey(v sdk.ValAddress) (key []byte) {
key = append(key, KeyPrefixFeederDelegation...)
return append(key, address.MustLengthPrefix(v)...)
}
// GetMissCounterKey - stored by *Validator* address
func GetMissCounterKey(v sdk.ValAddress) (key []byte) {
key = append(key, KeyPrefixMissCounter...)
return append(key, address.MustLengthPrefix(v)...)
}
// GetAggregateExchangeRatePrevoteKey - stored by *Validator* address
func GetAggregateExchangeRatePrevoteKey(v sdk.ValAddress) (key []byte) {
key = append(key, KeyPrefixAggregateExchangeRatePrevote...)
return append(key, address.MustLengthPrefix(v)...)
}
// GetAggregateExchangeRateVoteKey - stored by *Validator* address
func GetAggregateExchangeRateVoteKey(v sdk.ValAddress) (key []byte) {
key = append(key, KeyPrefixAggregateExchangeRateVote...)
return append(key, address.MustLengthPrefix(v)...)
}