-
Notifications
You must be signed in to change notification settings - Fork 181
/
keys.go
70 lines (57 loc) · 2.35 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
import (
"encoding/binary"
)
const (
// ModuleName is the name of the module
ModuleName = "slashing"
// StoreKey is the store key string for slashing
StoreKey = ModuleName
// RouterKey is the message route for slashing
RouterKey = ModuleName
// QuerierRoute is the querier route for slashing
QuerierRoute = ModuleName
)
// Keys for slashing store
// Items are stored with the following key: values
//
// - 0x01<consAddress_Bytes>: ValidatorSigningInfo
//
// - 0x02<consAddress_Bytes><period_Bytes>: bool
//
// - 0x03<accAddr_Bytes>: crypto.PubKey
var (
DefaultValue = []byte{0x01} // Value to store for slashing sequence
ValidatorSigningInfoKey = []byte{0x01} // Prefix for signing info
ValidatorMissedBlockBitArrayKey = []byte{0x02} // Prefix for missed block bit array
TotalSlashedAmountKey = []byte{0x04} // Prefix for total slashed amount stored in buffer
BufferValSlashingInfoKey = []byte{0x05} // Prefix for Slashing Info stored in buffer
TickValSlashingInfoKey = []byte{0x06} // Prefix for Slashing Info stored after tick tx
SlashingSequenceKey = []byte{0x07} // prefix for each key for slashing sequence map
TickCountKey = []byte{0x08} // key to store Tick counts
)
// GetValidatorSigningInfoKey - stored by *valID*
func GetValidatorSigningInfoKey(valID []byte) []byte {
return append(ValidatorSigningInfoKey, valID...)
}
// GetValidatorMissedBlockBitArrayPrefixKey - stored by *Consensus* address (not operator address)
func GetValidatorMissedBlockBitArrayPrefixKey(valID []byte) []byte {
return append(ValidatorMissedBlockBitArrayKey, valID...)
}
// GetValidatorMissedBlockBitArrayKey - stored by *Consensus* address (not operator address)
func GetValidatorMissedBlockBitArrayKey(valID []byte, i int64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, uint64(i))
return append(GetValidatorMissedBlockBitArrayPrefixKey(valID), b...)
}
// GetBufferValSlashingInfoKey - gets buffer val slashing info key
func GetBufferValSlashingInfoKey(id []byte) []byte {
return append(BufferValSlashingInfoKey, id...)
}
func GetTickValSlashingInfoKey(id []byte) []byte {
return append(TickValSlashingInfoKey, id...)
}
// GetSlashingSequenceKey returns slashing sequence key
func GetSlashingSequenceKey(sequence string) []byte {
return append(SlashingSequenceKey, []byte(sequence)...)
}