string -> []byte
This commit is contained in:
parent
35a80e6563
commit
6d80faface
@ -13,9 +13,9 @@ const (
|
||||
)
|
||||
|
||||
// nolint - Paramstore key constructor
|
||||
func ParamStoreKeyDepositProcedure() params.Key { return params.NewKey("depositprocedure") }
|
||||
func ParamStoreKeyVotingProcedure() params.Key { return params.NewKey("votingprocedure") }
|
||||
func ParamStoreKeyTallyingProcedure() params.Key { return params.NewKey("tallyingprocedure") }
|
||||
func ParamStoreKeyDepositProcedure() params.Key { return params.NewKey([]byte("depositprocedure")) }
|
||||
func ParamStoreKeyVotingProcedure() params.Key { return params.NewKey([]byte("votingprocedure")) }
|
||||
func ParamStoreKeyTallyingProcedure() params.Key { return params.NewKey([]byte("tallyingprocedure")) }
|
||||
|
||||
// Cached parameter store keys
|
||||
var (
|
||||
|
||||
@ -14,7 +14,7 @@ type KeyFieldPairs = space.KeyFieldPairs
|
||||
type ParamStruct = space.ParamStruct
|
||||
|
||||
// nolint - reexport
|
||||
func NewKey(keys ...string) Key {
|
||||
func NewKey(keys ...[]byte) Key {
|
||||
return space.NewKey(keys...)
|
||||
}
|
||||
func UnmarshalParamsFromMap(m map[string][]byte, cdc *codec.Codec, ps space.ParamStruct) error {
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package space
|
||||
|
||||
import (
|
||||
tmlibs "github.com/tendermint/tendermint/libs/common"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
@ -13,21 +11,23 @@ type Key struct {
|
||||
|
||||
// Appending two keys with '/' as separator
|
||||
// Checks alphanumericity
|
||||
func (k Key) Append(keys ...string) (res Key) {
|
||||
func (k Key) Append(keys ...[]byte) (res Key) {
|
||||
res.s = make([]byte, len(k.s))
|
||||
copy(res.s, k.s)
|
||||
|
||||
for _, key := range keys {
|
||||
if !tmlibs.IsASCIIText(key) {
|
||||
panic("parameter key expressions can only contain alphanumeric characters")
|
||||
for _, b := range key {
|
||||
if !(32 <= b && b <= 126) {
|
||||
panic("parameter key expressions can only contain alphanumeric characters")
|
||||
}
|
||||
}
|
||||
res.s = append(append(res.s, byte('/')), []byte(key)...)
|
||||
res.s = append(append(res.s, byte('/')), key...)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// NewKey constructs a key from a list of strings
|
||||
func NewKey(keys ...string) (res Key) {
|
||||
func NewKey(keys ...[]byte) (res Key) {
|
||||
if len(keys) < 1 {
|
||||
panic("length of parameter keys must not be zero")
|
||||
}
|
||||
|
||||
@ -14,13 +14,15 @@ const (
|
||||
)
|
||||
|
||||
// nolint - Key generators for parameter access
|
||||
func MaxEvidenceAgeKey() params.Key { return params.NewKey("MaxEvidenceAge") }
|
||||
func SignedBlocksWindowKey() params.Key { return params.NewKey("SignedBlocksWindow") }
|
||||
func MinSignedPerWindowKey() params.Key { return params.NewKey("MinSignedPerWindow") }
|
||||
func DoubleSignUnbondDurationKey() params.Key { return params.NewKey("DoubleSignUnbondDuration") }
|
||||
func DowntimeUnbondDurationKey() params.Key { return params.NewKey("DowntimeUnbondDuration") }
|
||||
func SlashFractionDoubleSignKey() params.Key { return params.NewKey("SlashFractionDoubleSign") }
|
||||
func SlashFractionDowntimeKey() params.Key { return params.NewKey("SlashFractionDowntime") }
|
||||
func MaxEvidenceAgeKey() params.Key { return params.NewKey([]byte("MaxEvidenceAge")) }
|
||||
func SignedBlocksWindowKey() params.Key { return params.NewKey([]byte("SignedBlocksWindow")) }
|
||||
func MinSignedPerWindowKey() params.Key { return params.NewKey([]byte("MinSignedPerWindow")) }
|
||||
func DoubleSignUnbondDurationKey() params.Key {
|
||||
return params.NewKey([]byte("DoubleSignUnbondDuration"))
|
||||
}
|
||||
func DowntimeUnbondDurationKey() params.Key { return params.NewKey([]byte("DowntimeUnbondDuration")) }
|
||||
func SlashFractionDoubleSignKey() params.Key { return params.NewKey([]byte("SlashFractionDoubleSign")) }
|
||||
func SlashFractionDowntimeKey() params.Key { return params.NewKey([]byte("SlashFractionDowntime")) }
|
||||
|
||||
// Cached parameter keys
|
||||
var (
|
||||
|
||||
@ -15,13 +15,13 @@ import (
|
||||
const defaultUnbondingTime time.Duration = 60 * 60 * 24 * 3 * time.Second
|
||||
|
||||
// nolint - Key generators for parameter access
|
||||
func KeyInflationRateChange() params.Key { return params.NewKey("InflationRateChange") }
|
||||
func KeyInflationMax() params.Key { return params.NewKey("InflationMax") }
|
||||
func KeyInflationMin() params.Key { return params.NewKey("InflationMin") }
|
||||
func KeyGoalBonded() params.Key { return params.NewKey("GoalBonded") }
|
||||
func KeyUnbondingTime() params.Key { return params.NewKey("UnbondingTime") }
|
||||
func KeyMaxValidators() params.Key { return params.NewKey("MaxValidators") }
|
||||
func KeyBondDenom() params.Key { return params.NewKey("BondDenom") }
|
||||
func KeyInflationRateChange() params.Key { return params.NewKey([]byte("InflationRateChange")) }
|
||||
func KeyInflationMax() params.Key { return params.NewKey([]byte("InflationMax")) }
|
||||
func KeyInflationMin() params.Key { return params.NewKey([]byte("InflationMin")) }
|
||||
func KeyGoalBonded() params.Key { return params.NewKey([]byte("GoalBonded")) }
|
||||
func KeyUnbondingTime() params.Key { return params.NewKey([]byte("UnbondingTime")) }
|
||||
func KeyMaxValidators() params.Key { return params.NewKey([]byte("MaxValidators")) }
|
||||
func KeyBondDenom() params.Key { return params.NewKey([]byte("BondDenom")) }
|
||||
|
||||
// Params defines the high level settings for staking
|
||||
type Params struct {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user