-
Notifications
You must be signed in to change notification settings - Fork 39
/
keys.go
80 lines (67 loc) · 2.52 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
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
)
// Keys for oracle store
// Items are stored with the following key: values
//
// - 0x01<denom_Bytes>: sdk.Dec
//
// - 0x02<valAddress_Bytes>: accAddress
//
// - 0x03<valAddress_Bytes>: int64
//
// - 0x04<valAddress_Bytes>: AggregateExchangeRatePrevote
//
// - 0x05<valAddress_Bytes>: AggregateExchangeRateVote
//
// - 0x06<denom_Bytes>: sdk.Dec
var (
// Keys for store prefixes
ExchangeRateKey = []byte{0x01} // prefix for each key to a rate
FeederDelegationKey = []byte{0x02} // prefix for each key to a feeder delegation
MissCounterKey = []byte{0x03} // prefix for each key to a miss counter
AggregateExchangeRatePrevoteKey = []byte{0x04} // prefix for each key to a aggregate prevote
AggregateExchangeRateVoteKey = []byte{0x05} // prefix for each key to a aggregate vote
TobinTaxKey = []byte{0x06} // prefix for each key to a tobin tax
)
// GetExchangeRateKey - stored by *denom*
func GetExchangeRateKey(denom string) []byte {
return append(ExchangeRateKey, []byte(denom)...)
}
// GetFeederDelegationKey - stored by *Validator* address
func GetFeederDelegationKey(v sdk.ValAddress) []byte {
return append(FeederDelegationKey, address.MustLengthPrefix(v)...)
}
// GetMissCounterKey - stored by *Validator* address
func GetMissCounterKey(v sdk.ValAddress) []byte {
return append(MissCounterKey, address.MustLengthPrefix(v)...)
}
// GetAggregateExchangeRatePrevoteKey - stored by *Validator* address
func GetAggregateExchangeRatePrevoteKey(v sdk.ValAddress) []byte {
return append(AggregateExchangeRatePrevoteKey, address.MustLengthPrefix(v)...)
}
// GetAggregateExchangeRateVoteKey - stored by *Validator* address
func GetAggregateExchangeRateVoteKey(v sdk.ValAddress) []byte {
return append(AggregateExchangeRateVoteKey, address.MustLengthPrefix(v)...)
}
// GetTobinTaxKey - stored by *denom* bytes
func GetTobinTaxKey(d string) []byte {
return append(TobinTaxKey, []byte(d)...)
}
// ExtractDenomFromTobinTaxKey - split denom from the tobin tax key
func ExtractDenomFromTobinTaxKey(key []byte) (denom string) {
denom = string(key[1:])
return
}