From 581cb2d2bac3356bc39ca840497c141169dc490f Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 8 Sep 2020 13:39:13 +0300 Subject: [PATCH] [#138] v2/object: Update to neofs-api jindo release Signed-off-by: Alex Vanin --- v2/object/convert.go | 44 ++++++++++++++++++++++++++++++---- v2/object/grpc/service.go | 22 +++++++++++++---- v2/object/grpc/service.pb.go | Bin 246028 -> 252479 bytes v2/object/marshal.go | 45 +++++++++++++++++++++++++++++++++++ v2/object/marshal_test.go | 6 ++++- v2/object/types.go | 40 ++++++++++++++++++++++++++++--- 6 files changed, 145 insertions(+), 12 deletions(-) diff --git a/v2/object/convert.go b/v2/object/convert.go index 7beb6405..a18d43f4 100644 --- a/v2/object/convert.go +++ b/v2/object/convert.go @@ -283,6 +283,42 @@ func HeaderFromGRPCMessage(m *object.Header) *Header { return h } +func HeaderWithSignatureToGRPCMessage(h *HeaderWithSignature) *object.HeaderWithSignature { + if h == nil { + return nil + } + + m := new(object.HeaderWithSignature) + + m.SetHeader( + HeaderToGRPCMessage(h.GetHeader()), + ) + + m.SetSignature( + refs.SignatureToGRPCMessage(h.GetSignature()), + ) + + return m +} + +func HeaderWithSignatureFromGRPCMessage(m *object.HeaderWithSignature) *HeaderWithSignature { + if m == nil { + return nil + } + + h := new(HeaderWithSignature) + + h.SetHeader( + HeaderFromGRPCMessage(m.GetHeader()), + ) + + h.SetSignature( + refs.SignatureFromGRPCMessage(m.GetSignature()), + ) + + return h +} + func ObjectToGRPCMessage(o *Object) *object.Object { if o == nil { return nil @@ -942,8 +978,8 @@ func GetHeaderPartFullToGRPCMessage(r *GetHeaderPartFull) *object.HeadResponse_B m := new(object.HeadResponse_Body_Header) - m.SetHeader( - HeaderToGRPCMessage(r.GetHeader()), + m.SetHeaderWithSignature( + HeaderWithSignatureToGRPCMessage(r.GetHeaderWithSignature()), ) return m @@ -956,8 +992,8 @@ func GetHeaderPartFullFromGRPCMessage(m *object.HeadResponse_Body_Header) *GetHe r := new(GetHeaderPartFull) - r.SetHeader( - HeaderFromGRPCMessage(m.GetHeader()), + r.SetHeaderWithSignature( + HeaderWithSignatureFromGRPCMessage(m.GetHeaderWithSignature()), ) return r diff --git a/v2/object/grpc/service.go b/v2/object/grpc/service.go index 515d3e81..025af1c9 100644 --- a/v2/object/grpc/service.go +++ b/v2/object/grpc/service.go @@ -330,8 +330,8 @@ func (m *HeadResponse_Body_ShortHeader) SetShortHeader(v *ShortHeader) { } } -// GetHeader returns object header. -func (m *HeadResponse_Body_Header) GetHeader() *Header { +// GetHeaderWithSignature returns object header. +func (m *HeadResponse_Body_Header) GetHeaderWithSignature() *HeaderWithSignature { if m != nil { return m.Header } @@ -339,13 +339,27 @@ func (m *HeadResponse_Body_Header) GetHeader() *Header { return nil } -// SetHeader sets object header. -func (m *HeadResponse_Body_Header) SetHeader(v *Header) { +// SetHeaderWithSignature sets object header. +func (m *HeadResponse_Body_Header) SetHeaderWithSignature(v *HeaderWithSignature) { if m != nil { m.Header = v } } +// SetHeader sets object header. +func (m *HeaderWithSignature) SetHeader(v *Header) { + if m != nil { + m.Header = v + } +} + +// SetSignature of the header. +func (m *HeaderWithSignature) SetSignature(v *refs.Signature) { + if m != nil { + m.Signature = v + } +} + // SetHeader sets full header of the object. func (m *HeadResponse_Body) SetHeader(v *HeadResponse_Body_Header) { if m != nil { diff --git a/v2/object/grpc/service.pb.go b/v2/object/grpc/service.pb.go index 2c8fc74f905fd6349a2b6be915702e0e08c3a060..46462c6880b0eed80cfe53469e5e38aa83842d40 100644 GIT binary patch delta 9385 zcmZviYm8l08HTe@r!$>#dZXM*OW9zA3T1lk7l~3^Fc3(zKqR7A_Bm&7W?<-)nKSet zl1+@^60}8@Ws4deG)PkYQF1Voc!7c>qH=2jKU4%7Nl@@Y{}=-SUF&^T%UsHj&7QT_ zTHo#c-tSxM^c!DW`NU%@4}AHa^s4Dy<8e5Vgvs>ycsS9#A#QcT(Ku?ylVP;89Zrp1 zzccDgPil_;eCb6aL!Dc9#o;BIcl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Gc_8f-m|3P1^Az@#`f+WezAcnUys#mZ+(#gj(mo0;kt z9$@vRtc(t$2Ion^mryYVvu{9$7|dB)JgqYQY-8@N^pj8QqF>u&5j8MiFiBB3PBk(W zVq<&b9|KqhVSk^zRC^qp_$CRI{1npZNIih{71a9*rZgbQcOrqCe+PmAIOitx3?w9@ z&k*4M1fpvie1Ow1TcuYpSF3UD(mod!zUj3A9|j}pipVe@vwHaaC2`EKre7LhF6I?E$A${~ zvV%iA9lgVt#k$jyo5cYCB?!1d5Z3Xd22Sk=IxZ4c+BHK6=w|ET%1IbkSckghtPhLq zj3Fv$?f&^x^3Sh@8|T+{|MvT&neU$LF1_-X`2Paz-aNeL=An8vUHZgs{_Z_5{^Wnw ClW|A@ diff --git a/v2/object/marshal.go b/v2/object/marshal.go index f19c54fe..c1ceea14 100644 --- a/v2/object/marshal.go +++ b/v2/object/marshal.go @@ -33,6 +33,9 @@ const ( hdrAttributesField = 10 hdrSplitField = 11 + hdrWithSigHeaderField = 1 + hdrWithSigSignatureField = 2 + objIDField = 1 objSignatureField = 2 objHeaderField = 3 @@ -385,6 +388,48 @@ func (h *Header) StableSize() (size int) { return size } +func (h *HeaderWithSignature) StableMarshal(buf []byte) ([]byte, error) { + if h == nil { + return []byte{}, nil + } + + if buf == nil { + buf = make([]byte, h.StableSize()) + } + + var ( + offset, n int + err error + ) + + n, err = proto.NestedStructureMarshal(hdrWithSigHeaderField, buf[offset:], h.header) + if err != nil { + return nil, err + } + + offset += n + + n, err = proto.NestedStructureMarshal(hdrWithSigSignatureField, buf[offset:], h.signature) + if err != nil { + return nil, err + } + + offset += n + + return buf, nil +} + +func (h *HeaderWithSignature) StableSize() (size int) { + if h == nil { + return 0 + } + + size += proto.NestedStructureSize(hdrVersionField, h.header) + size += proto.NestedStructureSize(hdrContainerIDField, h.signature) + + return size +} + func (o *Object) StableMarshal(buf []byte) ([]byte, error) { if o == nil { return []byte{}, nil diff --git a/v2/object/marshal_test.go b/v2/object/marshal_test.go index 04f3a390..e63683b1 100644 --- a/v2/object/marshal_test.go +++ b/v2/object/marshal_test.go @@ -590,8 +590,12 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody { short.SetShortHeader(generateShortHeader("short id")) part = short } else { + hdrWithSig := new(object.HeaderWithSignature) + hdrWithSig.SetHeader(generateHeader(30)) + hdrWithSig.SetSignature(generateSignature("sig", "key")) + full := new(object.GetHeaderPartFull) - full.SetHeader(generateHeader(30)) + full.SetHeaderWithSignature(hdrWithSig) part = full } diff --git a/v2/object/types.go b/v2/object/types.go index cdce248d..5c6c9ac4 100644 --- a/v2/object/types.go +++ b/v2/object/types.go @@ -57,6 +57,12 @@ type Header struct { split *SplitHeader } +type HeaderWithSignature struct { + header *Header + + signature *refs.Signature +} + type Object struct { objectID *refs.ObjectID @@ -136,7 +142,7 @@ type GetHeaderPart interface { } type GetHeaderPartFull struct { - hdr *Header + hdr *HeaderWithSignature } type GetHeaderPartShort struct { @@ -528,6 +534,34 @@ func (h *Header) SetSplit(v *SplitHeader) { } } +func (h *HeaderWithSignature) GetHeader() *Header { + if h != nil { + return h.header + } + + return nil +} + +func (h *HeaderWithSignature) SetHeader(v *Header) { + if h != nil { + h.header = v + } +} + +func (h *HeaderWithSignature) GetSignature() *refs.Signature { + if h != nil { + return h.signature + } + + return nil +} + +func (h *HeaderWithSignature) SetSignature(v *refs.Signature) { + if h != nil { + h.signature = v + } +} + func (o *Object) GetObjectID() *refs.ObjectID { if o != nil { return o.objectID @@ -1138,7 +1172,7 @@ func (r *HeadRequest) SetVerificationHeader(v *session.RequestVerificationHeader } } -func (h *GetHeaderPartFull) GetHeader() *Header { +func (h *GetHeaderPartFull) GetHeaderWithSignature() *HeaderWithSignature { if h != nil { return h.hdr } @@ -1146,7 +1180,7 @@ func (h *GetHeaderPartFull) GetHeader() *Header { return nil } -func (h *GetHeaderPartFull) SetHeader(v *Header) { +func (h *GetHeaderPartFull) SetHeaderWithSignature(v *HeaderWithSignature) { if h != nil { h.hdr = v }