[#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 33 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-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
github.com/multiformats/go-multihash v0.0.13 // indirect 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/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/neofs-crypto v0.3.0
github.com/nspcc-dev/tzhash v1.4.0 github.com/nspcc-dev/tzhash v1.4.0
github.com/panjf2000/ants/v2 v2.3.0 github.com/panjf2000/ants/v2 v2.3.0

2
go.sum
View file

@ -272,6 +272,8 @@ github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78 h1:stIa+nB
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200929122641-420d9560625b h1:zcfzW992l3ohrnLnRd6449vooUqHggGppLYSwcPc2vA= github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200929122641-420d9560625b h1:zcfzW992l3ohrnLnRd6449vooUqHggGppLYSwcPc2vA=
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200929122641-420d9560625b/go.mod h1:FsFd1z4YzoEgPlltsUgnqna9qhcF87RHYjot0pby2L4= github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200929122641-420d9560625b/go.mod h1:FsFd1z4YzoEgPlltsUgnqna9qhcF87RHYjot0pby2L4=
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201001070630-cf70026c7e42 h1:uiGv5T/NnTBTEnvbMAKnplRg+BK3wbC2UooV8ZnvpMQ=
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201001070630-cf70026c7e42/go.mod h1:FsFd1z4YzoEgPlltsUgnqna9qhcF87RHYjot0pby2L4=
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=

View file

@ -37,19 +37,14 @@ func (v *FormatValidator) Validate(obj *Object) error {
return errNilCID return errNilCID
} }
if err := v.validateSignatureKey(obj); err != nil { for ; obj != nil; obj = obj.GetParent() {
return errors.Wrapf(err, "(%T) could not validate signature key", v) 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 { if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
return errors.Wrapf(err, "(%T) could not validate header fields", v) 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)
} }
return nil return nil

View file

@ -67,3 +67,16 @@ func FromBytes(data []byte) (*Object, error) {
Object: o, Object: o,
}, nil }, 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" 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/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "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/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util" 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 // TODO: check if received parent has requested address
return &Response{ return &Response{
hdr: object.NewFromSDK(rightChild.GetParent()), hdr: rightChild.GetParent(),
rightChild: rightChild, rightChild: rightChild,
}, nil }, nil
} }

View file

@ -4,7 +4,6 @@ import (
"context" "context"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" 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/bucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query" "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 { func (f *searchQueryFilter) Pass(ctx context.Context, meta *localstore.ObjectMeta) *localstore.FilterResult {
loop: 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) { if !f.query.Match(obj) {
continue continue
} }

View file

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

View file

@ -61,7 +61,7 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
var parID *objectSDK.ID 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 := objectSDK.NewRawFromV2(par.ToV2())
rawPar.SetSessionToken(f.token) rawPar.SetSessionToken(f.token)

View file

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