-
Notifications
You must be signed in to change notification settings - Fork 43
/
keys.go
48 lines (36 loc) · 1.42 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
package types
import (
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)
const (
// ModuleName defines the module name
ModuleName = "sequencers"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the module's message route key
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
// Stub variable to store the operator address from the InitChain request
InitChainStubAddr = "initchainstubaddr"
)
var (
// Keys for store prefixes
SequencersKey = []byte{0x21} // prefix for each key to a sequencer
SequencersByConsAddrKey = []byte{0x22} // prefix for each key to a sequencer index, by pubkey
HistoricalInfoKey = []byte{0x50} // prefix for the historical info
)
// GetSequencerKey creates the key for the sequencer with address
func GetSequencerKey(operatorAddr sdk.ValAddress) []byte {
return append(SequencersKey, address.MustLengthPrefix(operatorAddr)...)
}
// GetSequencerByConsAddrKey creates the key for the sequencer with pubkey
func GetSequencerByConsAddrKey(addr sdk.ConsAddress) []byte {
return append(SequencersByConsAddrKey, address.MustLengthPrefix(addr)...)
}
// GetHistoricalInfoKey returns a key prefix for indexing HistoricalInfo objects.
func GetHistoricalInfoKey(height int64) []byte {
return append(HistoricalInfoKey, []byte(strconv.FormatInt(height, 10))...)
}