-
Notifications
You must be signed in to change notification settings - Fork 206
/
keys.go
58 lines (44 loc) · 1.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
package types
import (
"strings"
)
const (
// ModuleName defines the module name
ModuleName = "dualstaking"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey defines the module's message routing key
RouterKey = ModuleName
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_dualstaking"
// prefix for the delegations fixation store
DelegationPrefix = "delegation-fs"
// prefix for the delegators fixation store
DelegatorPrefix = "delegator-fs"
// prefix for the unbonding timer store
UnbondingPrefix = "unbonding-ts"
// empty provider consts
EMPTY_PROVIDER = "empty_provider"
EMPTY_PROVIDER_CHAINID = ""
)
func KeyPrefix(p string) []byte {
return []byte(p)
}
// DelegationKey returns the key/prefix for the Delegation entry in fixation store.
// Using " " (space) as spearator is safe because Bech32 forbids its use as part of
// the address (and is the only visible character that can be safely used).
// (reference https://en.bitcoin.it/wiki/BIP_0173#Specification)
func DelegationKey(provider, delegator, chainID string) string {
return provider + " " + delegator + " " + chainID
}
func DelegationKeyDecode(prefix string) (provider, delegator, chainID string) {
split := strings.Split(prefix, " ")
return split[0], split[1], split[2]
}
// DelegatorKey returns the key/prefix for the Delegator entry in fixation store.
func DelegatorKey(delegator string) string {
return delegator
}
func DelegatorKeyDecode(prefix string) (delegator string) {
return prefix
}