forked from TrueCloudLab/frostfs-node
[#1214] *: Use single Object
type in whole project
Remove `Object` and `RawObject` types from `pkg/core/object` package. Use `Object` type from NeoFS SDK Go library everywhere. Avoid using the deprecated elements. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
19ad349b27
commit
7ccd1625af
100 changed files with 847 additions and 965 deletions
|
@ -5,8 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
|
@ -15,7 +14,7 @@ import (
|
|||
type formatter struct {
|
||||
prm *FormatterParams
|
||||
|
||||
obj *object.RawObject
|
||||
obj *object.Object
|
||||
|
||||
sz uint64
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ func NewFormatTarget(p *FormatterParams) ObjectTarget {
|
|||
}
|
||||
}
|
||||
|
||||
func (f *formatter) WriteHeader(obj *object.RawObject) error {
|
||||
func (f *formatter) WriteHeader(obj *object.Object) error {
|
||||
f.obj = obj
|
||||
|
||||
return nil
|
||||
|
@ -72,26 +71,26 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
|||
|
||||
var (
|
||||
parID *oidSDK.ID
|
||||
parHdr *objectSDK.Object
|
||||
parHdr *object.Object
|
||||
)
|
||||
|
||||
if par := f.obj.Parent(); par != nil && par.Signature() == nil {
|
||||
rawPar := objectSDK.NewRawFromV2(par.ToV2())
|
||||
rawPar := object.NewFromV2(par.ToV2())
|
||||
|
||||
rawPar.SetSessionToken(f.prm.SessionToken)
|
||||
rawPar.SetCreationEpoch(curEpoch)
|
||||
|
||||
if err := objectSDK.SetIDWithSignature(f.prm.Key, rawPar); err != nil {
|
||||
if err := object.SetIDWithSignature(f.prm.Key, rawPar); err != nil {
|
||||
return nil, fmt.Errorf("could not finalize parent object: %w", err)
|
||||
}
|
||||
|
||||
parID = rawPar.ID()
|
||||
parHdr = rawPar.Object()
|
||||
parHdr = rawPar
|
||||
|
||||
f.obj.SetParent(parHdr)
|
||||
}
|
||||
|
||||
if err := objectSDK.SetIDWithSignature(f.prm.Key, f.obj.SDK()); err != nil {
|
||||
if err := object.SetIDWithSignature(f.prm.Key, f.obj); err != nil {
|
||||
return nil, fmt.Errorf("could not finalize object: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@ import (
|
|||
"hash"
|
||||
"io"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/checksum"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/tzhash/tz"
|
||||
)
|
||||
|
@ -20,7 +19,7 @@ type payloadSizeLimiter struct {
|
|||
|
||||
target ObjectTarget
|
||||
|
||||
current, parent *object.RawObject
|
||||
current, parent *object.Object
|
||||
|
||||
currentHashers, parentHashers []*payloadChecksumHasher
|
||||
|
||||
|
@ -28,9 +27,9 @@ type payloadSizeLimiter struct {
|
|||
|
||||
chunkWriter io.Writer
|
||||
|
||||
splitID *objectSDK.SplitID
|
||||
splitID *object.SplitID
|
||||
|
||||
parAttrs []*objectSDK.Attribute
|
||||
parAttrs []*object.Attribute
|
||||
}
|
||||
|
||||
type payloadChecksumHasher struct {
|
||||
|
@ -47,11 +46,11 @@ func NewPayloadSizeLimiter(maxSize uint64, targetInit TargetInitializer) ObjectT
|
|||
return &payloadSizeLimiter{
|
||||
maxSize: maxSize,
|
||||
targetInit: targetInit,
|
||||
splitID: objectSDK.NewSplitID(),
|
||||
splitID: object.NewSplitID(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *payloadSizeLimiter) WriteHeader(hdr *object.RawObject) error {
|
||||
func (s *payloadSizeLimiter) WriteHeader(hdr *object.Object) error {
|
||||
s.current = fromObject(hdr)
|
||||
|
||||
s.initialize()
|
||||
|
@ -86,8 +85,8 @@ func (s *payloadSizeLimiter) initialize() {
|
|||
s.initializeCurrent()
|
||||
}
|
||||
|
||||
func fromObject(obj *object.RawObject) *object.RawObject {
|
||||
res := object.NewRaw()
|
||||
func fromObject(obj *object.Object) *object.Object {
|
||||
res := object.New()
|
||||
res.SetContainerID(obj.ContainerID())
|
||||
res.SetOwnerID(obj.OwnerID())
|
||||
res.SetAttributes(obj.Attributes()...)
|
||||
|
@ -125,7 +124,7 @@ func (s *payloadSizeLimiter) initializeCurrent() {
|
|||
s.chunkWriter = io.MultiWriter(ws...)
|
||||
}
|
||||
|
||||
func payloadHashersForObject(obj *object.RawObject) []*payloadChecksumHasher {
|
||||
func payloadHashersForObject(obj *object.Object) []*payloadChecksumHasher {
|
||||
return []*payloadChecksumHasher{
|
||||
{
|
||||
hasher: sha256.New(),
|
||||
|
@ -171,7 +170,7 @@ func (s *payloadSizeLimiter) release(close bool) (*AccessIdentifiers, error) {
|
|||
if withParent {
|
||||
writeHashes(s.parentHashers)
|
||||
s.parent.SetPayloadSize(s.written)
|
||||
s.current.SetParent(s.parent.SDK().Object())
|
||||
s.current.SetParent(s.parent)
|
||||
}
|
||||
|
||||
// release current object
|
||||
|
@ -209,7 +208,7 @@ func writeHashes(hashers []*payloadChecksumHasher) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *payloadSizeLimiter) initializeLinking(parHdr *objectSDK.Object) {
|
||||
func (s *payloadSizeLimiter) initializeLinking(parHdr *object.Object) {
|
||||
s.current = fromObject(s.current)
|
||||
s.current.SetParent(parHdr)
|
||||
s.current.SetChildren(s.previous...)
|
||||
|
|
|
@ -3,8 +3,7 @@ package transformer
|
|||
import (
|
||||
"io"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
)
|
||||
|
||||
|
@ -14,7 +13,7 @@ import (
|
|||
type AccessIdentifiers struct {
|
||||
par, self *oidSDK.ID
|
||||
|
||||
parHdr *objectSDK.Object
|
||||
parHdr *object.Object
|
||||
}
|
||||
|
||||
// ObjectTarget is an interface of the object writer.
|
||||
|
@ -27,7 +26,7 @@ type ObjectTarget interface {
|
|||
// that depends on the implementation.
|
||||
//
|
||||
// Must not be called after Close call.
|
||||
WriteHeader(*object.RawObject) error
|
||||
WriteHeader(*object.Object) error
|
||||
|
||||
// Write writes object payload chunk.
|
||||
//
|
||||
|
@ -93,7 +92,7 @@ func (a *AccessIdentifiers) WithParentID(v *oidSDK.ID) *AccessIdentifiers {
|
|||
}
|
||||
|
||||
// Parent return identifier of the parent of the written object.
|
||||
func (a *AccessIdentifiers) Parent() *objectSDK.Object {
|
||||
func (a *AccessIdentifiers) Parent() *object.Object {
|
||||
if a != nil {
|
||||
return a.parHdr
|
||||
}
|
||||
|
@ -102,7 +101,7 @@ func (a *AccessIdentifiers) Parent() *objectSDK.Object {
|
|||
}
|
||||
|
||||
// WithParent returns AccessIdentifiers with passed parent identifier.
|
||||
func (a *AccessIdentifiers) WithParent(v *objectSDK.Object) *AccessIdentifiers {
|
||||
func (a *AccessIdentifiers) WithParent(v *object.Object) *AccessIdentifiers {
|
||||
res := a
|
||||
if res == nil {
|
||||
res = new(AccessIdentifiers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue