cosmos-sdk/store/validation.go
Aleksandr Bezobchuk 03bca7b791
feat(store/v2): Merge Feature Branch (#18150)
Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
Co-authored-by: yihuang <huang@crypto.com>
2023-10-18 18:03:43 +00:00

32 lines
621 B
Go

package store
var (
// 128K - 1
MaxKeyLength = (1 << 17) - 1
// 2G - 1
MaxValueLength = (1 << 31) - 1
)
// AssertValidKey checks if the key is valid, i.e. key is not nil, not empty and
// within length limit.
func AssertValidKey(key []byte) {
if len(key) == 0 {
panic("key is nil or empty")
}
if len(key) > MaxKeyLength {
panic("key is too large")
}
}
// AssertValidValue checks if the value is valid, i.e. value is not nil and
// within length limit.
func AssertValidValue(value []byte) {
if value == nil {
panic("value is nil")
}
if len(value) > MaxValueLength {
panic("value is too large")
}
}