/
keys.go
78 lines (62 loc) · 2.32 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
71
72
73
74
75
76
77
78
package types
import (
"encoding/binary"
"github.com/sge-network/sge/utils"
)
var _ binary.ByteOrder
const (
// ModuleName defines the module name
ModuleName = "bet"
// 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
// MemStoreKey defines the in-memory store key
MemStoreKey = "mem_bet"
)
const (
// betFeeCollector is the module account name for the bet fee collection module account.
betFeeCollector = "bet_fee_collector"
)
var (
// BetListPrefix is the prefix to retrieve all Bet
BetListPrefix = []byte{0x00}
// BetIDListPrefix is the prefix to retrieve all Bet IDs
BetIDListPrefix = []byte{0x01}
// BetStatsKey is the key for the bet statistics
BetStatsKey = []byte{0x02}
// PendingBetListPrefix is the prefix to retrieve all pending bets
PendingBetListPrefix = []byte{0x03}
// SettledBetListPrefix is the prefix to retrieve all settled bets
SettledBetListPrefix = []byte{0x04}
)
// BetListByCreatorPrefix returns prefix of the certain creator bet list.
func BetListByCreatorPrefix(creator string) []byte {
return append(BetListPrefix, utils.StrBytes(creator)...)
}
// BetIDKey returns key of a certain bet of a creator.
func BetIDKey(creator string, id uint64) []byte {
return append(utils.StrBytes(creator), utils.Uint64ToBytes(id)...)
}
// PendingBetListOfMarketPrefix returns prefix of
// pending bet list of a certain market .
func PendingBetListOfMarketPrefix(marketID string) []byte {
return append(PendingBetListPrefix, utils.StrBytes(marketID)...)
}
// PendingBetOfMarketKey return the key of
// a certain pending bets of a market.
func PendingBetOfMarketKey(marketID string, id uint64) []byte {
return append(utils.StrBytes(marketID), utils.Uint64ToBytes(id)...)
}
// SettledBetListOfBlockHeightPrefix returns prefix of
// settled bet list on a certain block height.
func SettledBetListOfBlockHeightPrefix(blockHeight int64) []byte {
return append(SettledBetListPrefix, utils.Int64ToBytes(blockHeight)...)
}
// SettledBetOfMarketKey return the key of
// settled bet list on a certain block height.
func SettledBetOfMarketKey(blockHeight int64, id uint64) []byte {
return append(utils.Int64ToBytes(blockHeight), utils.Uint64ToBytes(id)...)
}