/
keys.go
97 lines (76 loc) · 2.21 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
// Copyright 2021 ChainSafe Systems
// SPDX-License-Identifier: MIT
package types
const (
// ModuleName defines the module name
ModuleName = "chainlink"
// FeedDataStoreKey defines the store key for feed data
FeedDataStoreKey = ModuleName + "feedData"
// RoundStoreKey defines the store key for feed roundId
RoundStoreKey = ModuleName + "round"
// ModuleOwnerStoreKey defines the store key for module owner
ModuleOwnerStoreKey = ModuleName + "moduleOwner"
// FeedInfoStoreKey defines the store key for feed
FeedInfoStoreKey = ModuleName + "feedInfo"
// AccountInfoStoreKey defines the store key for chainlink accounts
AccountStoreKey = ModuleName + "account"
// RouterKey is the message route for slashing
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_chainlink"
)
func KeyPrefix(p string) []byte {
return []byte(p)
}
const (
// FeedDataKey FeedDataStore key pattern: types.FeedDataKey/feedId/roundId
FeedDataKey = "feedData"
// RoundIdKey RoundStore key pattern: types.RoundIdKey/feedId
RoundIdKey = "roundId"
// ModuleOwnerKey ModuleOwnerStore key pattern: types.ModuleOwnerKey/moduleOwnerAddress
ModuleOwnerKey = "moduleOwner"
// FeedInfoKey FeedInfoStore key pattern: types.FeedInfoKey/feedId
FeedInfoKey = "feed"
// AccountKey AccountStore key pattern: types.AccountKey/accAddr
AccountKey = "account"
)
func GetFeedDataKey(feedId, roundId string) []byte {
key := FeedDataKey + "/"
if len(feedId) > 0 {
key += feedId + "/"
if len(roundId) > 0 {
key += roundId
}
}
return KeyPrefix(key)
}
func GetRoundIdKey(feedId string) []byte {
key := RoundIdKey + "/"
if len(feedId) > 0 {
key += feedId
}
return KeyPrefix(key)
}
func GetModuleOwnerKey(moduleOwnerAddress string) []byte {
key := ModuleOwnerKey + "/"
if len(moduleOwnerAddress) > 0 {
key += moduleOwnerAddress
}
return KeyPrefix(key)
}
func GetFeedInfoKey(feedId string) []byte {
key := FeedInfoKey + "/"
if len(feedId) > 0 {
key += feedId
}
return KeyPrefix(key)
}
func GetAccountKey(account string) []byte {
key := AccountKey + "/"
if len(account) > 0 {
key += account
}
return KeyPrefix(key)
}