-
Notifications
You must be signed in to change notification settings - Fork 44
/
keys.go
70 lines (58 loc) · 2.22 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
package types
// DONTCOVER
const (
ModuleName = "subspaces"
RouterKey = ModuleName
StoreKey = ModuleName
ActionCreateSubspace = "create_subspace"
ActionEditSubspace = "edit_subspace"
ActionAddAdmin = "add_admin"
ActionRemoveAdmin = "remove_admin"
ActionRegisterUser = "register_user"
ActionUnregisterUser = "unregister_user"
ActionBlockUser = "block_user"
ActionUnblockUser = "unblock_user"
QuerierRoute = ModuleName
QuerySubspace = "subspace"
QuerySubspaces = "subspaces"
)
var (
adminPrefix = []byte("prefix")
registeredUserPrefix = []byte("user")
bannedUserPrefix = []byte("banned")
SubspaceStorePrefix = []byte("subspace")
)
// SubspaceStoreKey turns an id to a key used to store a subspace into the subspaces store
func SubspaceStoreKey(id string) []byte {
return append(SubspaceStorePrefix, []byte(id)...)
}
// SubspaceAdminsPrefix returns the prefix used to store each admin
// of the subspace with the given id
func SubspaceAdminsPrefix(id string) []byte {
return append([]byte(id), adminPrefix...)
}
// SubspaceAdminKey returns the key used to store the given admin as an admin
// of the subspace with the given id
func SubspaceAdminKey(id string, admin string) []byte {
return append(SubspaceAdminsPrefix(id), []byte(admin)...)
}
// SubspaceRegisteredUsersPrefix returns the prefix used to store each registered user
// of the subspace with the given id
func SubspaceRegisteredUsersPrefix(id string) []byte {
return append([]byte(id), registeredUserPrefix...)
}
// SubspaceRegisteredUserKey returns the key used to store the given user as a registered user
// of the subspace with the given id
func SubspaceRegisteredUserKey(id string, user string) []byte {
return append(SubspaceRegisteredUsersPrefix(id), []byte(user)...)
}
// SubspaceBannedUsersPrefix returns the prefix used to store each banned user
// of the subspace with the given id
func SubspaceBannedUsersPrefix(id string) []byte {
return append([]byte(id), bannedUserPrefix...)
}
// SubspaceBannedUserKey returns the key used to store the given user as a banned user
// of the subspace with the given id
func SubspaceBannedUserKey(id string, user string) []byte {
return append(SubspaceBannedUsersPrefix(id), []byte(user)...)
}