[#61] Update to latest neofs-api-go changes

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-01 14:42:17 +03:00 committed by Alex Vanin
parent f251645def
commit 1654df4d97
9 changed files with 31 additions and 24 deletions

2
go.mod
View file

@ -13,7 +13,7 @@ require (
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
github.com/multiformats/go-multihash v0.0.13 // indirect
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200929122641-420d9560625b
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201001070630-cf70026c7e42
github.com/nspcc-dev/neofs-crypto v0.3.0
github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.3.0

BIN
go.sum

Binary file not shown.

View file

@ -37,19 +37,14 @@ func (v *FormatValidator) Validate(obj *Object) error {
return errNilCID
}
if err := v.validateSignatureKey(obj); err != nil {
return errors.Wrapf(err, "(%T) could not validate signature key", v)
}
for ; obj != nil; obj = obj.GetParent() {
if err := v.validateSignatureKey(obj); err != nil {
return errors.Wrapf(err, "(%T) could not validate signature key", v)
}
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
return errors.Wrapf(err, "(%T) could not validate header fields", v)
}
par := NewFromSDK(obj.GetParent())
// validate parent object header
if par.GetID() != nil && len(obj.GetChildren()) == 0 {
return v.Validate(par)
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
return errors.Wrapf(err, "(%T) could not validate header fields", v)
}
}
return nil

View file

@ -67,3 +67,16 @@ func FromBytes(data []byte) (*Object, error) {
Object: o,
}, nil
}
// GetParent returns parent object.
func (o *Object) GetParent() *Object {
if o != nil {
if par := o.Object.GetParent(); par != nil {
return &Object{
Object: par,
}
}
}
return nil
}

View file

@ -6,7 +6,6 @@ import (
objectSDK "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/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/network"
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
@ -87,7 +86,7 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) {
// TODO: check if received parent has requested address
return &Response{
hdr: object.NewFromSDK(rightChild.GetParent()),
hdr: rightChild.GetParent(),
rightChild: rightChild,
}, nil
}

View file

@ -4,7 +4,6 @@ import (
"context"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
@ -47,7 +46,7 @@ func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) err
func (f *searchQueryFilter) Pass(ctx context.Context, meta *localstore.ObjectMeta) *localstore.FilterResult {
loop:
for obj := meta.Head(); obj.GetID() != nil; obj = object.NewFromSDK(obj.GetParent()) {
for obj := meta.Head(); obj != nil; obj = obj.GetParent() {
if !f.query.Match(obj) {
continue
}

View file

@ -100,7 +100,7 @@ func headerEqual(obj *object.Object, key, value string) bool {
case keyNoChildrenField:
return len(obj.GetChildren()) == 0
case keyParentIDField:
return idValue(obj.GetParent().GetID()) == value
return idValue(obj.GetParentID()) == value
case keyParentField:
return len(obj.GetChildren()) > 0
// TODO: add other headers

View file

@ -61,7 +61,7 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
var parID *objectSDK.ID
if par := f.obj.GetParent(); par != nil && par.ToV2().GetHeader() != nil {
if par := f.obj.GetParent(); par != nil {
rawPar := objectSDK.NewRawFromV2(par.ToV2())
rawPar.SetSessionToken(f.token)

View file

@ -76,6 +76,7 @@ func (s *payloadSizeLimiter) initialize() {
// initialize parent object once (after 1st object)
if ln == 1 {
s.parent = s.current
s.parent.ResetRelations()
s.parentHashers = s.currentHashers
s.current = fromObject(s.parent)
}
@ -206,19 +207,19 @@ func writeHashes(hashers []*payloadChecksumHasher) {
}
func (s *payloadSizeLimiter) initializeLinking() {
id := s.current.GetParent().GetID()
par := objectSDK.NewRaw()
par.SetID(id)
id := s.current.GetParentID()
s.current = fromObject(s.current)
s.current.SetParentID(id)
s.current.SetChildren(s.previous...)
s.current.SetParent(par.Object())
}
func (s *payloadSizeLimiter) writeChunk(chunk []byte) error {
// statement is true if the previous write of bytes reached exactly the boundary.
if s.written > 0 && s.written%s.maxSize == 0 {
// initialize blank split header
s.current.InitRelations()
// we need to release current object
if _, err := s.release(false); err != nil {
return errors.Wrap(err, "could not release object")