diff --git a/accounting/decimal.go b/accounting/decimal.go index 86782022..74755e75 100644 --- a/accounting/decimal.go +++ b/accounting/decimal.go @@ -50,7 +50,7 @@ func (d *Decimal) SetPrecision(p uint32) { // Marshal marshals Decimal into a protobuf binary form. func (d *Decimal) Marshal() ([]byte, error) { - return (*accounting.Decimal)(d).StableMarshal(nil) + return (*accounting.Decimal)(d).StableMarshal(nil), nil } // Unmarshal unmarshalls protobuf binary representation of Decimal. diff --git a/audit/result.go b/audit/result.go index 11cc8941..99fd8661 100644 --- a/audit/result.go +++ b/audit/result.go @@ -46,7 +46,7 @@ func (r *Result) ToV2() *audit.DataAuditResult { // Marshal marshals Result into a protobuf binary form. func (r *Result) Marshal() ([]byte, error) { - return (*audit.DataAuditResult)(r).StableMarshal(nil) + return (*audit.DataAuditResult)(r).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Result. diff --git a/checksum/checksum.go b/checksum/checksum.go index 19ad500d..baf08879 100644 --- a/checksum/checksum.go +++ b/checksum/checksum.go @@ -89,7 +89,7 @@ func Equal(cs1, cs2 *Checksum) bool { // Marshal marshals Checksum into a protobuf binary form. func (c *Checksum) Marshal() ([]byte, error) { - return (*refs.Checksum)(c).StableMarshal(nil) + return (*refs.Checksum)(c).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Checksum. diff --git a/container/announcement.go b/container/announcement.go index 1e41cf84..4fe1c527 100644 --- a/container/announcement.go +++ b/container/announcement.go @@ -68,7 +68,7 @@ func (a *UsedSpaceAnnouncement) ToV2() *container.UsedSpaceAnnouncement { // Marshal marshals UsedSpaceAnnouncement into a protobuf binary form. func (a *UsedSpaceAnnouncement) Marshal() ([]byte, error) { - return a.ToV2().StableMarshal(nil) + return a.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of UsedSpaceAnnouncement. diff --git a/container/container.go b/container/container.go index b9bff7b6..f6c7bcca 100644 --- a/container/container.go +++ b/container/container.go @@ -86,10 +86,7 @@ func NewContainerFromV2(c *container.Container) *Container { // CalculateID calculates container identifier // based on its structure. func CalculateID(c *Container) *cid.ID { - data, err := c.ToV2().StableMarshal(nil) - if err != nil { - panic(err) - } + data := c.ToV2().StableMarshal(nil) id := cid.New() id.SetSHA256(sha256.Sum256(data)) @@ -174,7 +171,7 @@ func (c *Container) SetSignature(sig *signature.Signature) { // Marshal marshals Container into a protobuf binary form. func (c *Container) Marshal() ([]byte, error) { - return c.v2.StableMarshal(nil) + return c.v2.StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Container. diff --git a/container/id/id.go b/container/id/id.go index 32f11998..94688bb8 100644 --- a/container/id/id.go +++ b/container/id/id.go @@ -71,7 +71,7 @@ func (id *ID) String() string { // Marshal marshals ID into a protobuf binary form. func (id *ID) Marshal() ([]byte, error) { - return (*refs.ContainerID)(id).StableMarshal(nil) + return (*refs.ContainerID)(id).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of ID. diff --git a/eacl/filter.go b/eacl/filter.go index 32bfaaa1..df66aef2 100644 --- a/eacl/filter.go +++ b/eacl/filter.go @@ -143,7 +143,7 @@ func NewFilterFromV2(filter *v2acl.HeaderFilter) *Filter { // Marshal marshals Filter into a protobuf binary form. func (f *Filter) Marshal() ([]byte, error) { - return f.ToV2().StableMarshal(nil) + return f.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Filter. diff --git a/eacl/record.go b/eacl/record.go index 722a4bc8..e307ac75 100644 --- a/eacl/record.go +++ b/eacl/record.go @@ -236,7 +236,7 @@ func NewRecordFromV2(record *v2acl.Record) *Record { // Marshal marshals Record into a protobuf binary form. func (r *Record) Marshal() ([]byte, error) { - return r.ToV2().StableMarshal(nil) + return r.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Record. diff --git a/eacl/table.go b/eacl/table.go index 0397b166..3c74d62d 100644 --- a/eacl/table.go +++ b/eacl/table.go @@ -168,7 +168,7 @@ func NewTableFromV2(table *v2acl.Table) *Table { // Marshal marshals Table into a protobuf binary form. func (t *Table) Marshal() ([]byte, error) { - return t.ToV2().StableMarshal(nil) + return t.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Table. diff --git a/eacl/target.go b/eacl/target.go index 8caea1c6..acf3a66c 100644 --- a/eacl/target.go +++ b/eacl/target.go @@ -124,7 +124,7 @@ func NewTargetFromV2(target *v2acl.Target) *Target { // Marshal marshals Target into a protobuf binary form. func (t *Target) Marshal() ([]byte, error) { - return t.ToV2().StableMarshal(nil) + return t.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Target. diff --git a/go.mod b/go.mod index 437be290..13270f7d 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.98.0 - github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 + github.com/nspcc-dev/neofs-api-go/v2 v2.12.2-0.20220427064503-870c1ffc0a9f github.com/stretchr/testify v1.7.0 go.uber.org/zap v1.18.1 google.golang.org/grpc v1.41.0 diff --git a/go.sum b/go.sum index b2836df7..be93101e 100644 --- a/go.sum +++ b/go.sum @@ -179,6 +179,8 @@ github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8Yd github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 h1:PVU2rLlG9S0jDe5eKyaUs4nKo/la+mN5pvz32Gib3qM= github.com/nspcc-dev/neofs-api-go/v2 v2.12.1/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU= +github.com/nspcc-dev/neofs-api-go/v2 v2.12.2-0.20220427064503-870c1ffc0a9f h1:hGMs65HYSKanUve3ipXHT260HtaO7gn5egQJeAEDvlA= +github.com/nspcc-dev/neofs-api-go/v2 v2.12.2-0.20220427064503-870c1ffc0a9f/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU= 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.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= diff --git a/netmap/filter.go b/netmap/filter.go index 3492fac3..0b358298 100644 --- a/netmap/filter.go +++ b/netmap/filter.go @@ -254,7 +254,7 @@ func (f *Filter) SetInnerFilters(fs ...Filter) { // Marshal marshals Filter into a protobuf binary form. func (f *Filter) Marshal() ([]byte, error) { - return (*netmap.Filter)(f).StableMarshal(nil) + return (*netmap.Filter)(f).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Filter. diff --git a/netmap/network_info.go b/netmap/network_info.go index 6234beb4..7af240d5 100644 --- a/netmap/network_info.go +++ b/netmap/network_info.go @@ -81,7 +81,7 @@ func (i *NetworkInfo) SetNetworkConfig(v *NetworkConfig) { // Marshal marshals NetworkInfo into a protobuf binary form. func (i *NetworkInfo) Marshal() ([]byte, error) { - return (*netmap.NetworkInfo)(i).StableMarshal(nil) + return (*netmap.NetworkInfo)(i).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of NetworkInfo. diff --git a/netmap/node_info.go b/netmap/node_info.go index 040589f7..2e4ba8d4 100644 --- a/netmap/node_info.go +++ b/netmap/node_info.go @@ -274,7 +274,7 @@ func (a *NodeAttribute) SetParentKeys(keys ...string) { // Marshal marshals NodeAttribute into a protobuf binary form. func (a *NodeAttribute) Marshal() ([]byte, error) { - return (*netmap.Attribute)(a).StableMarshal(nil) + return (*netmap.Attribute)(a).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of NodeAttribute. @@ -401,7 +401,7 @@ func (i *NodeInfo) SetState(s NodeState) { // Marshal marshals NodeInfo into a protobuf binary form. func (i *NodeInfo) Marshal() ([]byte, error) { - return (*netmap.NodeInfo)(i).StableMarshal(nil) + return (*netmap.NodeInfo)(i).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of NodeInfo. diff --git a/netmap/policy.go b/netmap/policy.go index aa1f3369..a5ef032a 100644 --- a/netmap/policy.go +++ b/netmap/policy.go @@ -139,7 +139,7 @@ func (p *PlacementPolicy) SetFilters(fs ...Filter) { // Marshal marshals PlacementPolicy into a protobuf binary form. func (p *PlacementPolicy) Marshal() ([]byte, error) { - return (*netmap.PlacementPolicy)(p).StableMarshal(nil) + return (*netmap.PlacementPolicy)(p).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of PlacementPolicy. diff --git a/netmap/replica.go b/netmap/replica.go index 3535cc1f..ddc09946 100644 --- a/netmap/replica.go +++ b/netmap/replica.go @@ -52,7 +52,7 @@ func (r *Replica) SetSelector(s string) { // Marshal marshals Replica into a protobuf binary form. func (r *Replica) Marshal() ([]byte, error) { - return (*netmap.Replica)(r).StableMarshal(nil) + return (*netmap.Replica)(r).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Replica. diff --git a/netmap/selector.go b/netmap/selector.go index eb69fe8b..b27e113b 100644 --- a/netmap/selector.go +++ b/netmap/selector.go @@ -256,7 +256,7 @@ func (s *Selector) SetFilter(f string) { // Marshal marshals Selector into a protobuf binary form. func (s *Selector) Marshal() ([]byte, error) { - return (*netmap.Selector)(s).StableMarshal(nil) + return (*netmap.Selector)(s).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Selector. diff --git a/object/address/address.go b/object/address/address.go index b7cb0ad4..44e391c4 100644 --- a/object/address/address.go +++ b/object/address/address.go @@ -99,7 +99,7 @@ func (a *Address) String() string { // Marshal marshals Address into a protobuf binary form. func (a *Address) Marshal() ([]byte, error) { - return (*refs.Address)(a).StableMarshal(nil) + return (*refs.Address)(a).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Address. diff --git a/object/attribute.go b/object/attribute.go index cc1ac42e..0e4ac9ed 100644 --- a/object/attribute.go +++ b/object/attribute.go @@ -54,7 +54,7 @@ func (a *Attribute) ToV2() *object.Attribute { // Marshal marshals Attribute into a protobuf binary form. func (a *Attribute) Marshal() ([]byte, error) { - return (*object.Attribute)(a).StableMarshal(nil) + return (*object.Attribute)(a).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Attribute. diff --git a/object/fmt.go b/object/fmt.go index 1ae7b4a6..d47b23fe 100644 --- a/object/fmt.go +++ b/object/fmt.go @@ -47,10 +47,7 @@ func VerifyPayloadChecksum(obj *Object) error { // CalculateID calculates identifier for the object. func CalculateID(obj *Object) (*oid.ID, error) { - data, err := obj.ToV2().GetHeader().StableMarshal(nil) - if err != nil { - return nil, err - } + data := obj.ToV2().GetHeader().StableMarshal(nil) id := oid.NewID() id.SetSHA256(sha256.Sum256(data)) diff --git a/object/id/id.go b/object/id/id.go index 4c3d0e47..0e431e03 100644 --- a/object/id/id.go +++ b/object/id/id.go @@ -73,7 +73,7 @@ func (id *ID) String() string { // Marshal marshals ID into a protobuf binary form. func (id *ID) Marshal() ([]byte, error) { - return (*refs.ObjectID)(id).StableMarshal(nil) + return (*refs.ObjectID)(id).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of ID. diff --git a/object/lock.go b/object/lock.go index 952822bb..735f1efd 100644 --- a/object/lock.go +++ b/object/lock.go @@ -64,12 +64,7 @@ func (x *Lock) WriteMembers(ids []oid.ID) { // Marshal encodes the Lock into a NeoFS protocol binary format. func (x Lock) Marshal() []byte { - data, err := (*v2object.Lock)(&x).StableMarshal(nil) - if err != nil { - panic(err) - } - - return data + return (*v2object.Lock)(&x).StableMarshal(nil) } // Unmarshal decodes the Lock from its NeoFS protocol binary representation. diff --git a/object/object.go b/object/object.go index ac394372..c13276e0 100644 --- a/object/object.go +++ b/object/object.go @@ -494,7 +494,7 @@ func (o *Object) InitRelations() { // Marshal marshals object into a protobuf binary form. func (o *Object) Marshal() ([]byte, error) { - return (*object.Object)(o).StableMarshal(nil) + return (*object.Object)(o).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of object. diff --git a/object/splitinfo.go b/object/splitinfo.go index 4a2fcfad..432053c9 100644 --- a/object/splitinfo.go +++ b/object/splitinfo.go @@ -59,7 +59,7 @@ func (s *SplitInfo) SetLink(v *oid.ID) { } func (s *SplitInfo) Marshal() ([]byte, error) { - return (*object.SplitInfo)(s).StableMarshal(nil) + return (*object.SplitInfo)(s).StableMarshal(nil), nil } func (s *SplitInfo) Unmarshal(data []byte) error { diff --git a/object/tombstone.go b/object/tombstone.go index 03bb05e9..986b074f 100644 --- a/object/tombstone.go +++ b/object/tombstone.go @@ -96,7 +96,7 @@ func (t *Tombstone) SetMembers(v []oid.ID) { // Marshal marshals Tombstone into a protobuf binary form. func (t *Tombstone) Marshal() ([]byte, error) { - return (*tombstone.Tombstone)(t).StableMarshal(nil) + return (*tombstone.Tombstone)(t).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Tombstone. diff --git a/owner/id.go b/owner/id.go index 98c2de9d..26bb37c9 100644 --- a/owner/id.go +++ b/owner/id.go @@ -127,7 +127,7 @@ func valid(rawID []byte) bool { // Marshal marshals ID into a protobuf binary form. func (id *ID) Marshal() ([]byte, error) { - return (*refs.OwnerID)(id).StableMarshal(nil) + return (*refs.OwnerID)(id).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of ID. diff --git a/reputation/peer.go b/reputation/peer.go index 5d50455d..118903cd 100644 --- a/reputation/peer.go +++ b/reputation/peer.go @@ -65,7 +65,7 @@ func (x *PeerID) String() string { // Marshal marshals PeerID into a protobuf binary form. func (x *PeerID) Marshal() ([]byte, error) { - return (*reputation.PeerID)(x).StableMarshal(nil) + return (*reputation.PeerID)(x).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of PeerID. diff --git a/reputation/trust.go b/reputation/trust.go index ec7eea7d..20600a59 100644 --- a/reputation/trust.go +++ b/reputation/trust.go @@ -76,7 +76,7 @@ func (x *Trust) Value() float64 { // Marshal marshals Trust into a protobuf binary form. func (x *Trust) Marshal() ([]byte, error) { - return (*reputation.Trust)(x).StableMarshal(nil) + return (*reputation.Trust)(x).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Trust. @@ -149,7 +149,7 @@ func (x *PeerToPeerTrust) Trust() *Trust { // Marshal marshals PeerToPeerTrust into a protobuf binary form. func (x *PeerToPeerTrust) Marshal() ([]byte, error) { - return (*reputation.PeerToPeerTrust)(x).StableMarshal(nil) + return (*reputation.PeerToPeerTrust)(x).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of PeerToPeerTrust. @@ -287,7 +287,7 @@ func (x *GlobalTrust) VerifySignature() error { // Marshal marshals GlobalTrust into a protobuf binary form. func (x *GlobalTrust) Marshal() ([]byte, error) { - return (*reputation.GlobalTrust)(x).StableMarshal(nil) + return (*reputation.GlobalTrust)(x).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of GlobalTrust. diff --git a/session/container.go b/session/container.go index ed754560..6c78e1be 100644 --- a/session/container.go +++ b/session/container.go @@ -116,7 +116,7 @@ func (x *ContainerContext) IsForSetEACL() bool { // Marshal marshals ContainerContext into a protobuf binary form. func (x *ContainerContext) Marshal() ([]byte, error) { - return x.ToV2().StableMarshal(nil) + return x.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of ContainerContext. diff --git a/session/object.go b/session/object.go index 8dfb3440..db588e1f 100644 --- a/session/object.go +++ b/session/object.go @@ -147,7 +147,7 @@ func (x *ObjectContext) IsForRangeHash() bool { // Marshal marshals ObjectContext into a protobuf binary form. func (x *ObjectContext) Marshal() ([]byte, error) { - return x.ToV2().StableMarshal(nil) + return x.ToV2().StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of ObjectContext. diff --git a/session/session.go b/session/session.go index 0c905a93..6c696cbe 100644 --- a/session/session.go +++ b/session/session.go @@ -248,8 +248,7 @@ func GetContainerContext(t *Token) *ContainerContext { // Marshal marshals Token into a protobuf binary form. func (t *Token) Marshal() ([]byte, error) { - return (*session.Token)(t). - StableMarshal(nil) + return (*session.Token)(t).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Token. diff --git a/signature/signature.go b/signature/signature.go index 75b78439..fdd87bf3 100644 --- a/signature/signature.go +++ b/signature/signature.go @@ -75,7 +75,7 @@ func (s *Signature) ToV2() *refs.Signature { // Marshal marshals Signature into a protobuf binary form. func (s *Signature) Marshal() ([]byte, error) { - return (*refs.Signature)(s).StableMarshal(nil) + return (*refs.Signature)(s).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Signature. diff --git a/storagegroup/storagegroup.go b/storagegroup/storagegroup.go index e3d09520..7cde7de3 100644 --- a/storagegroup/storagegroup.go +++ b/storagegroup/storagegroup.go @@ -116,7 +116,7 @@ func (sg *StorageGroup) ToV2() *storagegroup.StorageGroup { // Marshal marshals StorageGroup into a protobuf binary form. func (sg *StorageGroup) Marshal() ([]byte, error) { - return (*storagegroup.StorageGroup)(sg).StableMarshal(nil) + return (*storagegroup.StorageGroup)(sg).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of StorageGroup. diff --git a/subnet/id/id.go b/subnet/id/id.go index d1f530c2..9a198df2 100644 --- a/subnet/id/id.go +++ b/subnet/id/id.go @@ -67,7 +67,7 @@ func (x *ID) String() string { // Marshal encodes ID into a binary format of NeoFS API V2 protocol (Protocol Buffers with direct field order). func (x *ID) Marshal() ([]byte, error) { - return (*refs.SubnetID)(x).StableMarshal(nil) + return (*refs.SubnetID)(x).StableMarshal(nil), nil } // Unmarshal decodes ID from NeoFS API V2 binary format (see Marshal). Must not be called on nil. diff --git a/subnet/subnet.go b/subnet/subnet.go index f70f8763..a44ef1fc 100644 --- a/subnet/subnet.go +++ b/subnet/subnet.go @@ -26,7 +26,7 @@ func (x Info) WriteToV2(msg *subnet.Info) { // Marshal encodes Info into a binary format of NeoFS API V2 protocol (Protocol Buffers with direct field order). func (x *Info) Marshal() ([]byte, error) { - return (*subnet.Info)(x).StableMarshal(nil) + return (*subnet.Info)(x).StableMarshal(nil), nil } // Unmarshal decodes Info from NeoFS API V2 binary format (see Marshal). Must not be called on nil. diff --git a/token/bearer.go b/token/bearer.go index 3cd30884..e5aa1436 100644 --- a/token/bearer.go +++ b/token/bearer.go @@ -191,8 +191,7 @@ func (b *BearerToken) Marshal(bs ...[]byte) ([]byte, error) { buf = bs[0] } - return b.ToV2(). - StableMarshal(buf) + return b.ToV2().StableMarshal(buf), nil } // Unmarshal unmarshals protobuf binary representation of BearerToken. diff --git a/version/version.go b/version/version.go index 071ecbac..3feb0b64 100644 --- a/version/version.go +++ b/version/version.go @@ -70,7 +70,7 @@ func (v *Version) String() string { // Marshal marshals Version into a protobuf binary form. func (v *Version) Marshal() ([]byte, error) { - return (*refs.Version)(v).StableMarshal(nil) + return (*refs.Version)(v).StableMarshal(nil), nil } // Unmarshal unmarshals protobuf binary representation of Version.