-
Notifications
You must be signed in to change notification settings - Fork 193
/
keys.go
44 lines (32 loc) · 1.12 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
package types
import "encoding/binary"
const (
ModuleName = "ratelimit"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey is the message route for slashing
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
)
func KeyPrefix(p string) []byte {
return []byte(p)
}
var (
PathKeyPrefix = KeyPrefix("path")
RateLimitKeyPrefix = KeyPrefix("rate-limit")
PendingSendPacketPrefix = KeyPrefix("pending-send-packet")
DenomBlacklistKeyPrefix = KeyPrefix("denom-blacklist")
AddressWhitelistKeyPrefix = KeyPrefix("address-blacklist")
PendingSendPacketChannelLength int = 16
)
func GetPendingSendPacketKey(channelId string, sequenceNumber uint64) []byte {
channelIdBz := make([]byte, PendingSendPacketChannelLength)
copy(channelIdBz[:], channelId)
sequenceNumberBz := make([]byte, 8)
binary.BigEndian.PutUint64(sequenceNumberBz, sequenceNumber)
return append(channelIdBz, sequenceNumberBz...)
}
func GetAddressWhitelistKey(sender, receiver string) []byte {
return append(KeyPrefix(sender), KeyPrefix(receiver)...)
}