From f9d31118252c26c39ee3a0fc59eda4839dc9687f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 7 Feb 2022 18:45:03 +0300 Subject: [PATCH] [#1115] blobovnicza: remove `GetRange` method It is unused and incorrect as described in FIXME. Signed-off-by: Evgenii Stratonikov --- .../blobovnicza/get_range.go | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 pkg/local_object_storage/blobovnicza/get_range.go diff --git a/pkg/local_object_storage/blobovnicza/get_range.go b/pkg/local_object_storage/blobovnicza/get_range.go deleted file mode 100644 index b1476f50f..000000000 --- a/pkg/local_object_storage/blobovnicza/get_range.go +++ /dev/null @@ -1,72 +0,0 @@ -package blobovnicza - -import ( - "fmt" - - "github.com/nspcc-dev/neofs-node/pkg/core/object" - objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" - addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address" -) - -// GetRangePrm groups the parameters of GetRange operation. -type GetRangePrm struct { - addr *addressSDK.Address - - rng *objectSDK.Range -} - -// GetRangeRes groups resulting values of GetRange operation. -type GetRangeRes struct { - rngData []byte -} - -// SetAddress sets address of the requested object. -func (p *GetRangePrm) SetAddress(addr *addressSDK.Address) { - p.addr = addr -} - -// SetRange sets range of the requested payload data . -func (p *GetRangePrm) SetRange(rng *objectSDK.Range) { - p.rng = rng -} - -// RangeData returns the requested payload data range. -func (p *GetRangeRes) RangeData() []byte { - return p.rngData -} - -// GetRange reads range of the object from Blobovnicza by address. -// -// Returns any error encountered that -// did not allow to completely read the object. -// -// Returns ErrNotFound if requested object is not -// presented in Blobovnicza. Returns ErrRangeOutOfBounds -// if requested range is outside the payload. -func (b *Blobovnicza) GetRange(prm *GetRangePrm) (*GetRangeRes, error) { - res, err := b.Get(&GetPrm{ - addr: prm.addr, - }) - if err != nil { - return nil, err - } - - // FIXME: code below is incorrect because Get returns raw object data - // so we should unmarshal payload from it before. If blobovnicza - // stores objects in non-protocol format (e.g. compressed) - // then it should not provide GetRange method. - - from := prm.rng.GetOffset() - to := from + prm.rng.GetLength() - payload := res.obj - - if from > to { - return nil, fmt.Errorf("invalid range [%d:%d]", from, to) - } else if uint64(len(payload)) < to { - return nil, object.ErrRangeOutOfBounds - } - - return &GetRangeRes{ - rngData: payload[from:to], - }, nil -}