[#128] object: Move ID and Address in subpkg

This is done to prevent import cycles when `object` package needs any other
that requires `object.ID` or `object.Address`.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-01-25 19:20:32 +03:00 committed by Alex Vanin
parent 03560b84af
commit e8eac3997c
27 changed files with 200 additions and 158 deletions

View file

@ -4,7 +4,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/audit" "github.com/nspcc-dev/neofs-api-go/v2/audit"
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/neofs-sdk-go/version"
) )
@ -141,7 +141,7 @@ func (r *Result) SetRetries(v uint32) {
} }
// PassSG returns list of Storage Groups that passed audit PoR stage. // PassSG returns list of Storage Groups that passed audit PoR stage.
func (r *Result) PassSG() []*object.ID { func (r *Result) PassSG() []*oid.ID {
mV2 := (*audit.DataAuditResult)(r). mV2 := (*audit.DataAuditResult)(r).
GetPassSG() GetPassSG()
@ -149,17 +149,17 @@ func (r *Result) PassSG() []*object.ID {
return nil return nil
} }
m := make([]*object.ID, len(mV2)) m := make([]*oid.ID, len(mV2))
for i := range mV2 { for i := range mV2 {
m[i] = object.NewIDFromV2(mV2[i]) m[i] = oid.NewIDFromV2(mV2[i])
} }
return m return m
} }
// SetPassSG sets list of Storage Groups that passed audit PoR stage. // SetPassSG sets list of Storage Groups that passed audit PoR stage.
func (r *Result) SetPassSG(list []*object.ID) { func (r *Result) SetPassSG(list []*oid.ID) {
mV2 := (*audit.DataAuditResult)(r). mV2 := (*audit.DataAuditResult)(r).
GetPassSG() GetPassSG()
@ -183,7 +183,7 @@ func (r *Result) SetPassSG(list []*object.ID) {
} }
// FailSG returns list of Storage Groups that failed audit PoR stage. // FailSG returns list of Storage Groups that failed audit PoR stage.
func (r *Result) FailSG() []*object.ID { func (r *Result) FailSG() []*oid.ID {
mV2 := (*audit.DataAuditResult)(r). mV2 := (*audit.DataAuditResult)(r).
GetFailSG() GetFailSG()
@ -191,17 +191,17 @@ func (r *Result) FailSG() []*object.ID {
return nil return nil
} }
m := make([]*object.ID, len(mV2)) m := make([]*oid.ID, len(mV2))
for i := range mV2 { for i := range mV2 {
m[i] = object.NewIDFromV2(mV2[i]) m[i] = oid.NewIDFromV2(mV2[i])
} }
return m return m
} }
// SetFailSG sets list of Storage Groups that failed audit PoR stage. // SetFailSG sets list of Storage Groups that failed audit PoR stage.
func (r *Result) SetFailSG(list []*object.ID) { func (r *Result) SetFailSG(list []*oid.ID) {
mV2 := (*audit.DataAuditResult)(r). mV2 := (*audit.DataAuditResult)(r).
GetFailSG() GetFailSG()

View file

@ -7,8 +7,8 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/audit" "github.com/nspcc-dev/neofs-sdk-go/audit"
audittest "github.com/nspcc-dev/neofs-sdk-go/audit/test" audittest "github.com/nspcc-dev/neofs-sdk-go/audit/test"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/neofs-sdk-go/version"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -40,11 +40,11 @@ func TestResult(t *testing.T) {
r.SetRetries(retries) r.SetRetries(retries)
require.Equal(t, retries, r.Retries()) require.Equal(t, retries, r.Retries())
passSG := []*object.ID{objecttest.ID(), objecttest.ID()} passSG := []*oid.ID{test.ID(), test.ID()}
r.SetPassSG(passSG) r.SetPassSG(passSG)
require.Equal(t, passSG, r.PassSG()) require.Equal(t, passSG, r.PassSG())
failSG := []*object.ID{objecttest.ID(), objecttest.ID()} failSG := []*oid.ID{test.ID(), test.ID()}
r.SetFailSG(failSG) r.SetFailSG(failSG)
require.Equal(t, failSG, r.FailSG()) require.Equal(t, failSG, r.FailSG())

View file

@ -3,8 +3,8 @@ package audittest
import ( import (
"github.com/nspcc-dev/neofs-sdk-go/audit" "github.com/nspcc-dev/neofs-sdk-go/audit"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test" versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test"
) )
@ -30,8 +30,8 @@ func Result() *audit.Result {
[]byte("node3"), []byte("node3"),
[]byte("node4"), []byte("node4"),
}) })
x.SetPassSG([]*object.ID{objecttest.ID(), objecttest.ID()}) x.SetPassSG([]*oid.ID{test.ID(), test.ID()})
x.SetFailSG([]*object.ID{objecttest.ID(), objecttest.ID()}) x.SetFailSG([]*oid.ID{test.ID(), test.ID()})
return x return x
} }

View file

@ -17,6 +17,8 @@ import (
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object/address"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
signer "github.com/nspcc-dev/neofs-sdk-go/util/signature" signer "github.com/nspcc-dev/neofs-sdk-go/util/signature"
) )
@ -29,17 +31,17 @@ type PutObjectParams struct {
// ObjectAddressWriter is an interface of the // ObjectAddressWriter is an interface of the
// component that writes the object address. // component that writes the object address.
type ObjectAddressWriter interface { type ObjectAddressWriter interface {
SetAddress(*object.Address) SetAddress(*address.Address)
} }
type DeleteObjectParams struct { type DeleteObjectParams struct {
addr *object.Address addr *address.Address
tombTgt ObjectAddressWriter tombTgt ObjectAddressWriter
} }
type GetObjectParams struct { type GetObjectParams struct {
addr *object.Address addr *address.Address
raw bool raw bool
@ -49,7 +51,7 @@ type GetObjectParams struct {
} }
type ObjectHeaderParams struct { type ObjectHeaderParams struct {
addr *object.Address addr *address.Address
raw bool raw bool
@ -57,7 +59,7 @@ type ObjectHeaderParams struct {
} }
type RangeDataParams struct { type RangeDataParams struct {
addr *object.Address addr *address.Address
raw bool raw bool
@ -69,7 +71,7 @@ type RangeDataParams struct {
type RangeChecksumParams struct { type RangeChecksumParams struct {
tz bool tz bool
addr *object.Address addr *address.Address
rs []*object.Range rs []*object.Range
@ -186,14 +188,14 @@ func (p *PutObjectParams) PayloadReader() io.Reader {
type ObjectPutRes struct { type ObjectPutRes struct {
statusRes statusRes
id *object.ID id *oid.ID
} }
func (x *ObjectPutRes) setID(id *object.ID) { func (x *ObjectPutRes) setID(id *oid.ID) {
x.id = id x.id = id
} }
func (x ObjectPutRes) ID() *object.ID { func (x ObjectPutRes) ID() *oid.ID {
return x.id return x.id
} }
@ -317,14 +319,14 @@ func (c *Client) PutObject(ctx context.Context, p *PutObjectParams, opts ...Call
} }
// convert object identifier // convert object identifier
id := object.NewIDFromV2(resp.GetBody().GetObjectID()) id := oid.NewIDFromV2(resp.GetBody().GetObjectID())
res.setID(id) res.setID(id)
return res, nil return res, nil
} }
func (p *DeleteObjectParams) WithAddress(v *object.Address) *DeleteObjectParams { func (p *DeleteObjectParams) WithAddress(v *address.Address) *DeleteObjectParams {
if p != nil { if p != nil {
p.addr = v p.addr = v
} }
@ -332,7 +334,7 @@ func (p *DeleteObjectParams) WithAddress(v *object.Address) *DeleteObjectParams
return p return p
} }
func (p *DeleteObjectParams) Address() *object.Address { func (p *DeleteObjectParams) Address() *address.Address {
if p != nil { if p != nil {
return p.addr return p.addr
} }
@ -361,14 +363,14 @@ func (p *DeleteObjectParams) TombstoneAddressTarget() ObjectAddressWriter {
type ObjectDeleteRes struct { type ObjectDeleteRes struct {
statusRes statusRes
tombAddr *object.Address tombAddr *address.Address
} }
func (x ObjectDeleteRes) TombstoneAddress() *object.Address { func (x ObjectDeleteRes) TombstoneAddress() *address.Address {
return x.tombAddr return x.tombAddr
} }
func (x *ObjectDeleteRes) setTombstoneAddress(addr *object.Address) { func (x *ObjectDeleteRes) setTombstoneAddress(addr *address.Address) {
x.tombAddr = addr x.tombAddr = addr
} }
@ -444,12 +446,12 @@ func (c *Client) DeleteObject(ctx context.Context, p *DeleteObjectParams, opts .
addrv2 := resp.GetBody().GetTombstone() addrv2 := resp.GetBody().GetTombstone()
res.setTombstoneAddress(object.NewAddressFromV2(addrv2)) res.setTombstoneAddress(address.NewAddressFromV2(addrv2))
return res, nil return res, nil
} }
func (p *GetObjectParams) WithAddress(v *object.Address) *GetObjectParams { func (p *GetObjectParams) WithAddress(v *address.Address) *GetObjectParams {
if p != nil { if p != nil {
p.addr = v p.addr = v
} }
@ -457,7 +459,7 @@ func (p *GetObjectParams) WithAddress(v *object.Address) *GetObjectParams {
return p return p
} }
func (p *GetObjectParams) Address() *object.Address { func (p *GetObjectParams) Address() *address.Address {
if p != nil { if p != nil {
return p.addr return p.addr
} }
@ -753,7 +755,7 @@ loop:
return res, nil return res, nil
} }
func (p *ObjectHeaderParams) WithAddress(v *object.Address) *ObjectHeaderParams { func (p *ObjectHeaderParams) WithAddress(v *address.Address) *ObjectHeaderParams {
if p != nil { if p != nil {
p.addr = v p.addr = v
} }
@ -761,7 +763,7 @@ func (p *ObjectHeaderParams) WithAddress(v *object.Address) *ObjectHeaderParams
return p return p
} }
func (p *ObjectHeaderParams) Address() *object.Address { func (p *ObjectHeaderParams) Address() *address.Address {
if p != nil { if p != nil {
return p.addr return p.addr
} }
@ -937,7 +939,7 @@ func (c *Client) HeadObject(ctx context.Context, p *ObjectHeaderParams, opts ...
return res, nil return res, nil
} }
func (p *RangeDataParams) WithAddress(v *object.Address) *RangeDataParams { func (p *RangeDataParams) WithAddress(v *address.Address) *RangeDataParams {
if p != nil { if p != nil {
p.addr = v p.addr = v
} }
@ -945,7 +947,7 @@ func (p *RangeDataParams) WithAddress(v *object.Address) *RangeDataParams {
return p return p
} }
func (p *RangeDataParams) Address() *object.Address { func (p *RangeDataParams) Address() *address.Address {
if p != nil { if p != nil {
return p.addr return p.addr
} }
@ -1141,7 +1143,7 @@ func (c *Client) ObjectPayloadRangeData(ctx context.Context, p *RangeDataParams,
return res, nil return res, nil
} }
func (p *RangeChecksumParams) WithAddress(v *object.Address) *RangeChecksumParams { func (p *RangeChecksumParams) WithAddress(v *address.Address) *RangeChecksumParams {
if p != nil { if p != nil {
p.addr = v p.addr = v
} }
@ -1149,7 +1151,7 @@ func (p *RangeChecksumParams) WithAddress(v *object.Address) *RangeChecksumParam
return p return p
} }
func (p *RangeChecksumParams) Address() *object.Address { func (p *RangeChecksumParams) Address() *address.Address {
if p != nil { if p != nil {
return p.addr return p.addr
} }
@ -1329,14 +1331,14 @@ func (p *SearchObjectParams) SearchFilters() object.SearchFilters {
type ObjectSearchRes struct { type ObjectSearchRes struct {
statusRes statusRes
ids []*object.ID ids []*oid.ID
} }
func (x *ObjectSearchRes) setIDList(v []*object.ID) { func (x *ObjectSearchRes) setIDList(v []*oid.ID) {
x.ids = v x.ids = v
} }
func (x ObjectSearchRes) IDList() []*object.ID { func (x ObjectSearchRes) IDList() []*oid.ID {
return x.ids return x.ids
} }
@ -1394,7 +1396,7 @@ func (c *Client) SearchObjects(ctx context.Context, p *SearchObjectParams, opts
} }
var ( var (
searchResult []*object.ID searchResult []*oid.ID
resp = new(v2object.SearchResponse) resp = new(v2object.SearchResponse)
messageWas bool messageWas bool
@ -1437,7 +1439,7 @@ func (c *Client) SearchObjects(ctx context.Context, p *SearchObjectParams, opts
chunk := resp.GetBody().GetIDList() chunk := resp.GetBody().GetIDList()
for i := range chunk { for i := range chunk {
searchResult = append(searchResult, object.NewIDFromV2(chunk[i])) searchResult = append(searchResult, oid.NewIDFromV2(chunk[i]))
} }
} }

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner" "github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/neofs-sdk-go/version"
) )
@ -111,7 +112,7 @@ func (r *Record) AddObjectVersionFilter(m Match, v *version.Version) {
} }
// AddObjectIDFilter adds filter by object ID. // AddObjectIDFilter adds filter by object ID.
func (r *Record) AddObjectIDFilter(m Match, id *object.ID) { func (r *Record) AddObjectIDFilter(m Match, id *oid.ID) {
r.addObjectReservedFilter(m, fKeyObjID, id) r.addObjectReservedFilter(m, fKeyObjID, id)
} }

View file

@ -10,7 +10,7 @@ import (
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test" ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test" versiontest "github.com/nspcc-dev/neofs-sdk-go/version/test"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -156,7 +156,7 @@ func TestRecord_ToV2(t *testing.T) {
func TestReservedRecords(t *testing.T) { func TestReservedRecords(t *testing.T) {
var ( var (
v = versiontest.Version() v = versiontest.Version()
oid = objecttest.ID() oid = test.ID()
cid = cidtest.ID() cid = cidtest.ID()
ownerid = ownertest.ID() ownerid = ownertest.ID()
h = checksumtest.Checksum() h = checksumtest.Checksum()

View file

@ -1,4 +1,4 @@
package object package address
import ( import (
"errors" "errors"
@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
// Address represents v2-compatible object address. // Address represents v2-compatible object address.
@ -55,13 +56,13 @@ func (a *Address) SetContainerID(id *cid.ID) {
} }
// ObjectID returns object identifier. // ObjectID returns object identifier.
func (a *Address) ObjectID() *ID { func (a *Address) ObjectID() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*refs.Address)(a).GetObjectID()) (*refs.Address)(a).GetObjectID())
} }
// SetObjectID sets object identifier. // SetObjectID sets object identifier.
func (a *Address) SetObjectID(id *ID) { func (a *Address) SetObjectID(id *oid.ID) {
(*refs.Address)(a).SetObjectID(id.ToV2()) (*refs.Address)(a).SetObjectID(id.ToV2())
} }
@ -69,7 +70,7 @@ func (a *Address) SetObjectID(id *ID) {
func (a *Address) Parse(s string) error { func (a *Address) Parse(s string) error {
var ( var (
err error err error
oid = NewID() oid = oid.NewID()
id = cid.New() id = cid.New()
parts = strings.Split(s, addressSeparator) parts = strings.Split(s, addressSeparator)
) )

View file

@ -1,4 +1,4 @@
package object package address
import ( import (
"strings" "strings"
@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -22,7 +23,7 @@ func TestAddress_SetContainerID(t *testing.T) {
func TestAddress_SetObjectID(t *testing.T) { func TestAddress_SetObjectID(t *testing.T) {
a := NewAddress() a := NewAddress()
oid := randID(t) oid := oidtest.ID()
a.SetObjectID(oid) a.SetObjectID(oid)
@ -32,8 +33,7 @@ func TestAddress_SetObjectID(t *testing.T) {
func TestAddress_Parse(t *testing.T) { func TestAddress_Parse(t *testing.T) {
cid := cidtest.ID() cid := cidtest.ID()
oid := NewID() oid := oidtest.ID()
oid.SetSHA256(randSHA256Checksum(t))
t.Run("should parse successful", func(t *testing.T) { t.Run("should parse successful", func(t *testing.T) {
s := strings.Join([]string{cid.String(), oid.String()}, addressSeparator) s := strings.Join([]string{cid.String(), oid.String()}, addressSeparator)
@ -62,7 +62,7 @@ func TestAddress_Parse(t *testing.T) {
func TestAddressEncoding(t *testing.T) { func TestAddressEncoding(t *testing.T) {
a := NewAddress() a := NewAddress()
a.SetObjectID(randID(t)) a.SetObjectID(oidtest.ID())
a.SetContainerID(cidtest.ID()) a.SetContainerID(cidtest.ID())
t.Run("binary", func(t *testing.T) { t.Run("binary", func(t *testing.T) {

View file

@ -0,0 +1,17 @@
package address
import (
"github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object/address"
"github.com/nspcc-dev/neofs-sdk-go/object/id/test"
)
// Address returns random object.Address.
func Address() *address.Address {
x := address.NewAddress()
x.SetContainerID(cidtest.ID())
x.SetObjectID(test.ID())
return x
}

View file

@ -8,6 +8,7 @@ import (
signatureV2 "github.com/nspcc-dev/neofs-api-go/v2/signature" signatureV2 "github.com/nspcc-dev/neofs-api-go/v2/signature"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/signature" "github.com/nspcc-dev/neofs-sdk-go/signature"
sigutil "github.com/nspcc-dev/neofs-sdk-go/util/signature" sigutil "github.com/nspcc-dev/neofs-sdk-go/util/signature"
) )
@ -45,13 +46,13 @@ func VerifyPayloadChecksum(obj *Object) error {
} }
// CalculateID calculates identifier for the object. // CalculateID calculates identifier for the object.
func CalculateID(obj *Object) (*ID, error) { func CalculateID(obj *Object) (*oid.ID, error) {
data, err := obj.ToV2().GetHeader().StableMarshal(nil) data, err := obj.ToV2().GetHeader().StableMarshal(nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
id := NewID() id := oid.NewID()
id.SetSHA256(sha256.Sum256(data)) id.SetSHA256(sha256.Sum256(data))
return id, nil return id, nil
@ -85,7 +86,7 @@ func VerifyID(obj *Object) error {
return nil return nil
} }
func CalculateIDSignature(key *ecdsa.PrivateKey, id *ID) (*signature.Signature, error) { func CalculateIDSignature(key *ecdsa.PrivateKey, id *oid.ID) (*signature.Signature, error) {
sig := signature.New() sig := signature.New()
if err := sigutil.SignDataWithHandler( if err := sigutil.SignDataWithHandler(

View file

@ -1,4 +1,4 @@
package object package oid
import ( import (
"bytes" "bytes"

View file

@ -1,4 +1,4 @@
package object package oid
import ( import (
"crypto/rand" "crypto/rand"
@ -11,6 +11,20 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func randID(t *testing.T) *ID {
id := NewID()
id.SetSHA256(randSHA256Checksum(t))
return id
}
func randSHA256Checksum(t *testing.T) (cs [sha256.Size]byte) {
_, err := rand.Read(cs[:])
require.NoError(t, err)
return
}
func TestIDV2(t *testing.T) { func TestIDV2(t *testing.T) {
id := NewID() id := NewID()

View file

@ -0,0 +1,26 @@
package test
import (
"crypto/sha256"
"math/rand"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// ID returns random object.ID.
func ID() *oid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return idWithChecksum(checksum)
}
// idWithChecksum returns object.ID initialized
// with specified checksum.
func idWithChecksum(cs [sha256.Size]byte) *oid.ID {
id := oid.NewID()
id.SetSHA256(cs)
return id
}

View file

@ -4,6 +4,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/object" "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner" "github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session" "github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/signature" "github.com/nspcc-dev/neofs-sdk-go/signature"
@ -48,7 +49,7 @@ func (o *RawObject) Object() *Object {
} }
// SetID sets object identifier. // SetID sets object identifier.
func (o *RawObject) SetID(v *ID) { func (o *RawObject) SetID(v *oid.ID) {
o.setID(v) o.setID(v)
} }
@ -103,12 +104,12 @@ func (o *RawObject) SetAttributes(v ...*Attribute) {
} }
// SetPreviousID sets identifier of the previous sibling object. // SetPreviousID sets identifier of the previous sibling object.
func (o *RawObject) SetPreviousID(v *ID) { func (o *RawObject) SetPreviousID(v *oid.ID) {
o.setPreviousID(v) o.setPreviousID(v)
} }
// SetChildren sets list of the identifiers of the child objects. // SetChildren sets list of the identifiers of the child objects.
func (o *RawObject) SetChildren(v ...*ID) { func (o *RawObject) SetChildren(v ...*oid.ID) {
o.setChildren(v...) o.setChildren(v...)
} }
@ -118,7 +119,7 @@ func (o *RawObject) SetSplitID(id *SplitID) {
} }
// SetParentID sets identifier of the parent object. // SetParentID sets identifier of the parent object.
func (o *RawObject) SetParentID(v *ID) { func (o *RawObject) SetParentID(v *oid.ID) {
o.setParentID(v) o.setParentID(v)
} }

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/object" "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test" ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test" sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
"github.com/nspcc-dev/neofs-sdk-go/signature" "github.com/nspcc-dev/neofs-sdk-go/signature"
@ -15,8 +16,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func randID(t *testing.T) *ID { func randID(t *testing.T) *oid.ID {
id := NewID() id := oid.NewID()
id.SetSHA256(randSHA256Checksum(t)) id.SetSHA256(randSHA256Checksum(t))
return id return id
@ -121,7 +122,6 @@ func TestRawObject_SetCreationEpoch(t *testing.T) {
func TestRawObject_SetPayloadChecksum(t *testing.T) { func TestRawObject_SetPayloadChecksum(t *testing.T) {
obj := NewRaw() obj := NewRaw()
cs := checksum.New() cs := checksum.New()
cs.SetSHA256(randSHA256Checksum(t)) cs.SetSHA256(randSHA256Checksum(t))
@ -175,7 +175,7 @@ func TestRawObject_SetChildren(t *testing.T) {
obj.SetChildren(id1, id2) obj.SetChildren(id1, id2)
require.Equal(t, []*ID{id1, id2}, obj.Children()) require.Equal(t, []*oid.ID{id1, id2}, obj.Children())
} }
func TestRawObject_SetSplitID(t *testing.T) { func TestRawObject_SetSplitID(t *testing.T) {

View file

@ -5,6 +5,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner" "github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session" "github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/signature" "github.com/nspcc-dev/neofs-sdk-go/signature"
@ -45,14 +46,14 @@ func (o *rwObject) setSplitFields(setter func(*object.SplitHeader)) {
} }
// ID returns object identifier. // ID returns object identifier.
func (o *rwObject) ID() *ID { func (o *rwObject) ID() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*object.Object)(o). (*object.Object)(o).
GetObjectID(), GetObjectID(),
) )
} }
func (o *rwObject) setID(v *ID) { func (o *rwObject) setID(v *oid.ID) {
(*object.Object)(o). (*object.Object)(o).
SetObjectID(v.ToV2()) SetObjectID(v.ToV2())
} }
@ -205,8 +206,8 @@ func (o *rwObject) setAttributes(v ...*Attribute) {
} }
// PreviousID returns identifier of the previous sibling object. // PreviousID returns identifier of the previous sibling object.
func (o *rwObject) PreviousID() *ID { func (o *rwObject) PreviousID() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*object.Object)(o). (*object.Object)(o).
GetHeader(). GetHeader().
GetSplit(). GetSplit().
@ -214,29 +215,29 @@ func (o *rwObject) PreviousID() *ID {
) )
} }
func (o *rwObject) setPreviousID(v *ID) { func (o *rwObject) setPreviousID(v *oid.ID) {
o.setSplitFields(func(split *object.SplitHeader) { o.setSplitFields(func(split *object.SplitHeader) {
split.SetPrevious(v.ToV2()) split.SetPrevious(v.ToV2())
}) })
} }
// Children return list of the identifiers of the child objects. // Children return list of the identifiers of the child objects.
func (o *rwObject) Children() []*ID { func (o *rwObject) Children() []*oid.ID {
ids := (*object.Object)(o). ids := (*object.Object)(o).
GetHeader(). GetHeader().
GetSplit(). GetSplit().
GetChildren() GetChildren()
res := make([]*ID, 0, len(ids)) res := make([]*oid.ID, 0, len(ids))
for i := range ids { for i := range ids {
res = append(res, NewIDFromV2(ids[i])) res = append(res, oid.NewIDFromV2(ids[i]))
} }
return res return res
} }
func (o *rwObject) setChildren(v ...*ID) { func (o *rwObject) setChildren(v ...*oid.ID) {
ids := make([]*refs.ObjectID, 0, len(v)) ids := make([]*refs.ObjectID, 0, len(v))
for i := range v { for i := range v {
@ -266,8 +267,8 @@ func (o *rwObject) setSplitID(id *SplitID) {
} }
// ParentID returns identifier of the parent object. // ParentID returns identifier of the parent object.
func (o *rwObject) ParentID() *ID { func (o *rwObject) ParentID() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*object.Object)(o). (*object.Object)(o).
GetHeader(). GetHeader().
GetSplit(). GetSplit().
@ -275,7 +276,7 @@ func (o *rwObject) ParentID() *ID {
) )
} }
func (o *rwObject) setParentID(v *ID) { func (o *rwObject) setParentID(v *oid.ID) {
o.setSplitFields(func(split *object.SplitHeader) { o.setSplitFields(func(split *object.SplitHeader) {
split.SetParent(v.ToV2()) split.SetParent(v.ToV2())
}) })

View file

@ -6,6 +6,7 @@ import (
v2object "github.com/nspcc-dev/neofs-api-go/v2/object" v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner" "github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/neofs-sdk-go/version"
) )
@ -262,12 +263,12 @@ func (f *SearchFilters) AddPhyFilter() {
} }
// AddParentIDFilter adds filter by parent identifier. // AddParentIDFilter adds filter by parent identifier.
func (f *SearchFilters) AddParentIDFilter(m SearchMatchType, id *ID) { func (f *SearchFilters) AddParentIDFilter(m SearchMatchType, id *oid.ID) {
f.addReservedFilter(m, fKeyParent, id) f.addReservedFilter(m, fKeyParent, id)
} }
// AddObjectIDFilter adds filter by object identifier. // AddObjectIDFilter adds filter by object identifier.
func (f *SearchFilters) AddObjectIDFilter(m SearchMatchType, id *ID) { func (f *SearchFilters) AddObjectIDFilter(m SearchMatchType, id *oid.ID) {
f.addReservedFilter(m, fKeyObjectID, id) f.addReservedFilter(m, fKeyObjectID, id)
} }

View file

@ -7,6 +7,7 @@ import (
v2object "github.com/nspcc-dev/neofs-api-go/v2/object" v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -99,12 +100,12 @@ func TestSearchFilters_AddPhyFilter(t *testing.T) {
require.Equal(t, "", f.Value()) require.Equal(t, "", f.Value())
} }
func testOID() *object.ID { func testOID() *oid.ID {
cs := [sha256.Size]byte{} cs := [sha256.Size]byte{}
rand.Read(cs[:]) rand.Read(cs[:])
id := object.NewID() id := oid.NewID()
id.SetSHA256(cs) id.SetSHA256(cs)
return id return id

View file

@ -2,6 +2,7 @@ package object
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/object" "github.com/nspcc-dev/neofs-api-go/v2/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
type SplitInfo object.SplitInfo type SplitInfo object.SplitInfo
@ -39,21 +40,21 @@ func (s *SplitInfo) SetSplitID(v *SplitID) {
(*object.SplitInfo)(s).SetSplitID(v.ToV2()) (*object.SplitInfo)(s).SetSplitID(v.ToV2())
} }
func (s *SplitInfo) LastPart() *ID { func (s *SplitInfo) LastPart() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*object.SplitInfo)(s).GetLastPart()) (*object.SplitInfo)(s).GetLastPart())
} }
func (s *SplitInfo) SetLastPart(v *ID) { func (s *SplitInfo) SetLastPart(v *oid.ID) {
(*object.SplitInfo)(s).SetLastPart(v.ToV2()) (*object.SplitInfo)(s).SetLastPart(v.ToV2())
} }
func (s *SplitInfo) Link() *ID { func (s *SplitInfo) Link() *oid.ID {
return NewIDFromV2( return oid.NewIDFromV2(
(*object.SplitInfo)(s).GetLink()) (*object.SplitInfo)(s).GetLink())
} }
func (s *SplitInfo) SetLink(v *ID) { func (s *SplitInfo) SetLink(v *oid.ID) {
(*object.SplitInfo)(s).SetLink(v.ToV2()) (*object.SplitInfo)(s).SetLink(v.ToV2())
} }

View file

@ -6,6 +6,7 @@ import (
objv2 "github.com/nspcc-dev/neofs-api-go/v2/object" objv2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -43,11 +44,11 @@ func TestSplitInfo(t *testing.T) {
}) })
} }
func generateID() *object.ID { func generateID() *oid.ID {
var buf [32]byte var buf [32]byte
_, _ = rand.Read(buf[:]) _, _ = rand.Read(buf[:])
id := object.NewID() id := oid.NewID()
id.SetSHA256(buf) id.SetSHA256(buf)
return id return id

View file

@ -1,47 +1,18 @@
package objecttest package objecttest
import ( import (
"crypto/sha256"
"math/rand"
"github.com/google/uuid" "github.com/google/uuid"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/object/id/test"
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test" ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test" sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
sigtest "github.com/nspcc-dev/neofs-sdk-go/signature/test" sigtest "github.com/nspcc-dev/neofs-sdk-go/signature/test"
"github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/neofs-sdk-go/version"
) )
// ID returns random object.ID.
func ID() *object.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return IDWithChecksum(checksum)
}
// IDWithChecksum returns object.ID initialized
// with specified checksum.
func IDWithChecksum(cs [sha256.Size]byte) *object.ID {
id := object.NewID()
id.SetSHA256(cs)
return id
}
// Address returns random object.Address.
func Address() *object.Address {
x := object.NewAddress()
x.SetContainerID(cidtest.ID())
x.SetObjectID(ID())
return x
}
// Range returns random object.Range. // Range returns random object.Range.
func Range() *object.Range { func Range() *object.Range {
x := object.NewRange() x := object.NewRange()
@ -74,7 +45,7 @@ func SplitID() *object.SplitID {
func generateRaw(withParent bool) *object.RawObject { func generateRaw(withParent bool) *object.RawObject {
x := object.NewRaw() x := object.NewRaw()
x.SetID(ID()) x.SetID(test.ID())
x.SetSessionToken(sessiontest.Token()) x.SetSessionToken(sessiontest.Token())
x.SetPayload([]byte{1, 2, 3}) x.SetPayload([]byte{1, 2, 3})
x.SetOwnerID(ownertest.ID()) x.SetOwnerID(ownertest.ID())
@ -83,9 +54,9 @@ func generateRaw(withParent bool) *object.RawObject {
x.SetVersion(version.Current()) x.SetVersion(version.Current())
x.SetPayloadSize(111) x.SetPayloadSize(111)
x.SetCreationEpoch(222) x.SetCreationEpoch(222)
x.SetPreviousID(ID()) x.SetPreviousID(test.ID())
x.SetParentID(ID()) x.SetParentID(test.ID())
x.SetChildren(ID(), ID()) x.SetChildren(test.ID(), test.ID())
x.SetAttributes(Attribute(), Attribute()) x.SetAttributes(Attribute(), Attribute())
x.SetSplitID(SplitID()) x.SetSplitID(SplitID())
x.SetPayloadChecksum(checksumtest.Checksum()) x.SetPayloadChecksum(checksumtest.Checksum())
@ -115,7 +86,7 @@ func Tombstone() *object.Tombstone {
x.SetSplitID(SplitID()) x.SetSplitID(SplitID())
x.SetExpirationEpoch(13) x.SetExpirationEpoch(13)
x.SetMembers([]*object.ID{ID(), ID()}) x.SetMembers([]*oid.ID{test.ID(), test.ID()})
return x return x
} }
@ -125,8 +96,8 @@ func SplitInfo() *object.SplitInfo {
x := object.NewSplitInfo() x := object.NewSplitInfo()
x.SetSplitID(SplitID()) x.SetSplitID(SplitID())
x.SetLink(ID()) x.SetLink(test.ID())
x.SetLastPart(ID()) x.SetLastPart(test.ID())
return x return x
} }
@ -135,7 +106,7 @@ func SplitInfo() *object.SplitInfo {
func SearchFilters() object.SearchFilters { func SearchFilters() object.SearchFilters {
x := object.NewSearchFilters() x := object.NewSearchFilters()
x.AddObjectIDFilter(object.MatchStringEqual, ID()) x.AddObjectIDFilter(object.MatchStringEqual, test.ID())
x.AddObjectContainerIDFilter(object.MatchStringNotEqual, cidtest.ID()) x.AddObjectContainerIDFilter(object.MatchStringNotEqual, cidtest.ID())
return x return x

View file

@ -3,6 +3,7 @@ package object
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/tombstone" "github.com/nspcc-dev/neofs-api-go/v2/tombstone"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
// Tombstone represents v2-compatible tombstone structure. // Tombstone represents v2-compatible tombstone structure.
@ -54,7 +55,7 @@ func (t *Tombstone) SetSplitID(v *SplitID) {
} }
// Members returns list of objects to be deleted. // Members returns list of objects to be deleted.
func (t *Tombstone) Members() []*ID { func (t *Tombstone) Members() []*oid.ID {
msV2 := (*tombstone.Tombstone)(t). msV2 := (*tombstone.Tombstone)(t).
GetMembers() GetMembers()
@ -62,17 +63,17 @@ func (t *Tombstone) Members() []*ID {
return nil return nil
} }
ms := make([]*ID, 0, len(msV2)) ms := make([]*oid.ID, 0, len(msV2))
for i := range msV2 { for i := range msV2 {
ms = append(ms, NewIDFromV2(msV2[i])) ms = append(ms, oid.NewIDFromV2(msV2[i]))
} }
return ms return ms
} }
// SetMembers sets list of objects to be deleted. // SetMembers sets list of objects to be deleted.
func (t *Tombstone) SetMembers(v []*ID) { func (t *Tombstone) SetMembers(v []*oid.ID) {
var ms []*refs.ObjectID var ms []*refs.ObjectID
if v != nil { if v != nil {

View file

@ -6,15 +6,16 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neofs-api-go/v2/tombstone" "github.com/nspcc-dev/neofs-api-go/v2/tombstone"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func generateIDList(sz int) []*ID { func generateIDList(sz int) []*oid.ID {
res := make([]*ID, sz) res := make([]*oid.ID, sz)
cs := [sha256.Size]byte{} cs := [sha256.Size]byte{}
for i := 0; i < sz; i++ { for i := 0; i < sz; i++ {
res[i] = NewID() res[i] = oid.NewID()
rand.Read(cs[:]) rand.Read(cs[:])
res[i].SetSHA256(cs) res[i].SetSHA256(cs)
} }

View file

@ -22,6 +22,7 @@ import (
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/eacl" "github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner" "github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session" "github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/token" "github.com/nspcc-dev/neofs-sdk-go/token"
@ -157,14 +158,14 @@ type Pool interface {
} }
type Object interface { type Object interface {
PutObject(ctx context.Context, params *client.PutObjectParams, opts ...CallOption) (*object.ID, error) PutObject(ctx context.Context, params *client.PutObjectParams, opts ...CallOption) (*oid.ID, error)
DeleteObject(ctx context.Context, params *client.DeleteObjectParams, opts ...CallOption) error DeleteObject(ctx context.Context, params *client.DeleteObjectParams, opts ...CallOption) error
GetObject(ctx context.Context, params *client.GetObjectParams, opts ...CallOption) (*object.Object, error) GetObject(ctx context.Context, params *client.GetObjectParams, opts ...CallOption) (*object.Object, error)
GetObjectHeader(ctx context.Context, params *client.ObjectHeaderParams, opts ...CallOption) (*object.Object, error) GetObjectHeader(ctx context.Context, params *client.ObjectHeaderParams, opts ...CallOption) (*object.Object, error)
ObjectPayloadRangeData(ctx context.Context, params *client.RangeDataParams, opts ...CallOption) ([]byte, error) ObjectPayloadRangeData(ctx context.Context, params *client.RangeDataParams, opts ...CallOption) ([]byte, error)
ObjectPayloadRangeSHA256(ctx context.Context, params *client.RangeChecksumParams, opts ...CallOption) ([][32]byte, error) ObjectPayloadRangeSHA256(ctx context.Context, params *client.RangeChecksumParams, opts ...CallOption) ([][32]byte, error)
ObjectPayloadRangeTZ(ctx context.Context, params *client.RangeChecksumParams, opts ...CallOption) ([][64]byte, error) ObjectPayloadRangeTZ(ctx context.Context, params *client.RangeChecksumParams, opts ...CallOption) ([][64]byte, error)
SearchObject(ctx context.Context, params *client.SearchObjectParams, opts ...CallOption) ([]*object.ID, error) SearchObject(ctx context.Context, params *client.SearchObjectParams, opts ...CallOption) ([]*oid.ID, error)
} }
type Container interface { type Container interface {
@ -540,7 +541,7 @@ func (p *pool) checkSessionTokenErr(err error, address string) bool {
return false return false
} }
func (p *pool) PutObject(ctx context.Context, params *client.PutObjectParams, opts ...CallOption) (*object.ID, error) { func (p *pool) PutObject(ctx context.Context, params *client.PutObjectParams, opts ...CallOption) (*oid.ID, error) {
cfg := cfgFromOpts(append(opts, useDefaultSession())...) cfg := cfgFromOpts(append(opts, useDefaultSession())...)
cp, options, err := p.conn(ctx, cfg) cp, options, err := p.conn(ctx, cfg)
if err != nil { if err != nil {
@ -729,7 +730,7 @@ func (p *pool) ObjectPayloadRangeTZ(ctx context.Context, params *client.RangeChe
return hs, nil return hs, nil
} }
func (p *pool) SearchObject(ctx context.Context, params *client.SearchObjectParams, opts ...CallOption) ([]*object.ID, error) { func (p *pool) SearchObject(ctx context.Context, params *client.SearchObjectParams, opts ...CallOption) ([]*oid.ID, error) {
cfg := cfgFromOpts(append(opts, useDefaultSession())...) cfg := cfgFromOpts(append(opts, useDefaultSession())...)
cp, options, err := p.conn(ctx, cfg) cp, options, err := p.conn(ctx, cfg)
if err != nil { if err != nil {

View file

@ -4,7 +4,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/storagegroup" "github.com/nspcc-dev/neofs-api-go/v2/storagegroup"
"github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/checksum"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
// StorageGroup represents v2-compatible storage group. // StorageGroup represents v2-compatible storage group.
@ -67,17 +67,17 @@ func (sg *StorageGroup) SetExpirationEpoch(epoch uint64) {
// Members returns strictly ordered list of // Members returns strictly ordered list of
// storage group member objects. // storage group member objects.
func (sg *StorageGroup) Members() []*object.ID { func (sg *StorageGroup) Members() []*oid.ID {
mV2 := (*storagegroup.StorageGroup)(sg).GetMembers() mV2 := (*storagegroup.StorageGroup)(sg).GetMembers()
if mV2 == nil { if mV2 == nil {
return nil return nil
} }
m := make([]*object.ID, len(mV2)) m := make([]*oid.ID, len(mV2))
for i := range mV2 { for i := range mV2 {
m[i] = object.NewIDFromV2(mV2[i]) m[i] = oid.NewIDFromV2(mV2[i])
} }
return m return m
@ -85,7 +85,7 @@ func (sg *StorageGroup) Members() []*object.ID {
// SetMembers sets strictly ordered list of // SetMembers sets strictly ordered list of
// storage group member objects. // storage group member objects.
func (sg *StorageGroup) SetMembers(members []*object.ID) { func (sg *StorageGroup) SetMembers(members []*oid.ID) {
mV2 := (*storagegroup.StorageGroup)(sg).GetMembers() mV2 := (*storagegroup.StorageGroup)(sg).GetMembers()
if members == nil { if members == nil {

View file

@ -5,8 +5,8 @@ import (
storagegroupV2 "github.com/nspcc-dev/neofs-api-go/v2/storagegroup" storagegroupV2 "github.com/nspcc-dev/neofs-api-go/v2/storagegroup"
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/nspcc-dev/neofs-sdk-go/storagegroup" "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
storagegrouptest "github.com/nspcc-dev/neofs-sdk-go/storagegroup/test" storagegrouptest "github.com/nspcc-dev/neofs-sdk-go/storagegroup/test"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -27,7 +27,7 @@ func TestStorageGroup(t *testing.T) {
sg.SetExpirationEpoch(exp) sg.SetExpirationEpoch(exp)
require.Equal(t, exp, sg.ExpirationEpoch()) require.Equal(t, exp, sg.ExpirationEpoch())
members := []*object.ID{objecttest.ID(), objecttest.ID()} members := []*oid.ID{test.ID(), test.ID()}
sg.SetMembers(members) sg.SetMembers(members)
require.Equal(t, members, sg.Members()) require.Equal(t, members, sg.Members())
} }

View file

@ -2,8 +2,8 @@ package storagegrouptest
import ( import (
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test" checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
"github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/test" "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/nspcc-dev/neofs-sdk-go/storagegroup" "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
) )
@ -14,7 +14,7 @@ func StorageGroup() *storagegroup.StorageGroup {
x.SetExpirationEpoch(66) x.SetExpirationEpoch(66)
x.SetValidationDataSize(322) x.SetValidationDataSize(322)
x.SetValidationDataHash(checksumtest.Checksum()) x.SetValidationDataHash(checksumtest.Checksum())
x.SetMembers([]*object.ID{objecttest.ID(), objecttest.ID()}) x.SetMembers([]*oid.ID{test.ID(), test.ID()})
return x return x
} }