/
keys.go
60 lines (50 loc) · 1.59 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
package ibc
import (
"github.com/cosmos/cosmos-sdk/stack"
"github.com/cosmos/cosmos-sdk/state"
)
const (
// this is the prefix for the list of chains
// we otherwise use the chainid as prefix, so this must not be an
// alpha-numeric byte
prefixChains = "**"
prefixInput = "i"
prefixOutput = "o"
)
// HandlerKey is used for the global permission info
func HandlerKey() []byte {
return []byte{0x2}
}
// ChainsKey is the key to get info on all chains
func ChainsKey() []byte {
return stack.PrefixedKey(prefixChains, state.SetKey())
}
// ChainKey is the key to get info on one chain
func ChainKey(chainID string) []byte {
bkey := state.MakeBKey([]byte(chainID))
return stack.PrefixedKey(prefixChains, bkey)
}
// QueueInKey is the key to get newest of the input queue from this chain
func QueueInKey(chainID string) []byte {
return stack.PrefixedKey(chainID,
stack.PrefixedKey(prefixInput,
state.QueueTailKey()))
}
// QueueOutKey is the key to get v of the output queue from this chain
func QueueOutKey(chainID string) []byte {
return stack.PrefixedKey(chainID,
stack.PrefixedKey(prefixOutput,
state.QueueTailKey()))
}
// QueueInPacketKey is the key to get given packet from this chain's input queue
func QueueInPacketKey(chainID string, seq int64) []byte {
return stack.PrefixedKey(chainID,
stack.PrefixedKey(prefixInput,
state.QueueItemKey(seq)))
}
// QueueOutPacketKey is the key to get given packet from this chain's output queue
func QueueOutPacketKey(chainID string, seq int64) []byte {
return stack.PrefixedKey(chainID,
stack.PrefixedKey(prefixOutput,
state.QueueItemKey(seq)))
}