limits: new package with storage limits

Packages like core/state or core/mpt shouldn't import whole core/storage just
to get some constant value, it's not a good dependency.
This commit is contained in:
Roman Khimov 2022-07-08 19:51:59 +03:00
parent 9987afea4c
commit 8cd7b93208
10 changed files with 36 additions and 25 deletions

View file

@ -4,8 +4,8 @@ import (
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/config/limits"
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/storage"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
)
@ -81,10 +81,10 @@ func getContextInternal(ic *interop.Context, isReadOnly bool) error {
}
func putWithContext(ic *interop.Context, stc *Context, key []byte, value []byte) error {
if len(key) > storage.MaxStorageKeyLen {
if len(key) > limits.MaxStorageKeyLen {
return errors.New("key is too big")
}
if len(value) > storage.MaxStorageValueLen {
if len(value) > limits.MaxStorageValueLen {
return errors.New("value is too big")
}
if stc.ReadOnly {