[#186] object/range: Use new storage engine for work

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-19 11:28:58 +03:00 committed by Alex Vanin
parent 9b32f131c0
commit 14442a0801
2 changed files with 7 additions and 15 deletions

View file

@ -4,7 +4,7 @@ import (
"io"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/pkg/errors"
)
@ -13,24 +13,16 @@ type localRangeWriter struct {
rng *object.Range
storage *localstore.Storage
storage *engine.StorageEngine
}
func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) {
obj, err := l.storage.Get(l.addr)
rngData, err := engine.GetRange(l.storage, l.addr, l.rng)
if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
}
payload := obj.Payload()
left := l.rng.GetOffset()
right := left + l.rng.GetLength()
if ln := uint64(len(payload)); ln < right {
return 0, errors.Errorf("(%T) object range is out-of-boundaries (size %d, range [%d:%d]", l, ln, left, right)
}
n, err := w.Write(payload[left:right])
n, err := w.Write(rngData)
return int64(n), err
}

View file

@ -8,7 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
@ -28,7 +28,7 @@ type Option func(*cfg)
type cfg struct {
keyStorage *objutil.KeyStorage
localStore *localstore.Storage
localStore *engine.StorageEngine
cnrSrc container.Source
@ -140,7 +140,7 @@ func WithKeyStorage(v *objutil.KeyStorage) Option {
}
}
func WithLocalStorage(v *localstore.Storage) Option {
func WithLocalStorage(v *engine.StorageEngine) Option {
return func(c *cfg) {
c.localStore = v
}