From 14442a0801dbc60fe8529f4319948f01a13911db Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 19 Nov 2020 11:28:58 +0300 Subject: [PATCH] [#186] object/range: Use new storage engine for work Signed-off-by: Leonard Lyubich --- pkg/services/object/range/local.go | 16 ++++------------ pkg/services/object/range/service.go | 6 +++--- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pkg/services/object/range/local.go b/pkg/services/object/range/local.go index f57b0fcbc..994b13d82 100644 --- a/pkg/services/object/range/local.go +++ b/pkg/services/object/range/local.go @@ -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 } diff --git a/pkg/services/object/range/service.go b/pkg/services/object/range/service.go index ed12b4630..72f03118e 100644 --- a/pkg/services/object/range/service.go +++ b/pkg/services/object/range/service.go @@ -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 }