[#138] v2/object: Update to neofs-api jindo release

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-09-08 13:39:13 +03:00 committed by Stanislav Bogatyrev
parent c0cc4a4374
commit 581cb2d2ba
6 changed files with 145 additions and 12 deletions

View file

@ -283,6 +283,42 @@ func HeaderFromGRPCMessage(m *object.Header) *Header {
return h 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 { func ObjectToGRPCMessage(o *Object) *object.Object {
if o == nil { if o == nil {
return nil return nil
@ -942,8 +978,8 @@ func GetHeaderPartFullToGRPCMessage(r *GetHeaderPartFull) *object.HeadResponse_B
m := new(object.HeadResponse_Body_Header) m := new(object.HeadResponse_Body_Header)
m.SetHeader( m.SetHeaderWithSignature(
HeaderToGRPCMessage(r.GetHeader()), HeaderWithSignatureToGRPCMessage(r.GetHeaderWithSignature()),
) )
return m return m
@ -956,8 +992,8 @@ func GetHeaderPartFullFromGRPCMessage(m *object.HeadResponse_Body_Header) *GetHe
r := new(GetHeaderPartFull) r := new(GetHeaderPartFull)
r.SetHeader( r.SetHeaderWithSignature(
HeaderFromGRPCMessage(m.GetHeader()), HeaderWithSignatureFromGRPCMessage(m.GetHeaderWithSignature()),
) )
return r return r

View file

@ -330,8 +330,8 @@ func (m *HeadResponse_Body_ShortHeader) SetShortHeader(v *ShortHeader) {
} }
} }
// GetHeader returns object header. // GetHeaderWithSignature returns object header.
func (m *HeadResponse_Body_Header) GetHeader() *Header { func (m *HeadResponse_Body_Header) GetHeaderWithSignature() *HeaderWithSignature {
if m != nil { if m != nil {
return m.Header return m.Header
} }
@ -339,13 +339,27 @@ func (m *HeadResponse_Body_Header) GetHeader() *Header {
return nil return nil
} }
// SetHeader sets object header. // SetHeaderWithSignature sets object header.
func (m *HeadResponse_Body_Header) SetHeader(v *Header) { func (m *HeadResponse_Body_Header) SetHeaderWithSignature(v *HeaderWithSignature) {
if m != nil { if m != nil {
m.Header = v 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. // SetHeader sets full header of the object.
func (m *HeadResponse_Body) SetHeader(v *HeadResponse_Body_Header) { func (m *HeadResponse_Body) SetHeader(v *HeadResponse_Body_Header) {
if m != nil { if m != nil {

Binary file not shown.

View file

@ -33,6 +33,9 @@ const (
hdrAttributesField = 10 hdrAttributesField = 10
hdrSplitField = 11 hdrSplitField = 11
hdrWithSigHeaderField = 1
hdrWithSigSignatureField = 2
objIDField = 1 objIDField = 1
objSignatureField = 2 objSignatureField = 2
objHeaderField = 3 objHeaderField = 3
@ -385,6 +388,48 @@ func (h *Header) StableSize() (size int) {
return size 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) { func (o *Object) StableMarshal(buf []byte) ([]byte, error) {
if o == nil { if o == nil {
return []byte{}, nil return []byte{}, nil

View file

@ -590,8 +590,12 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody {
short.SetShortHeader(generateShortHeader("short id")) short.SetShortHeader(generateShortHeader("short id"))
part = short part = short
} else { } else {
hdrWithSig := new(object.HeaderWithSignature)
hdrWithSig.SetHeader(generateHeader(30))
hdrWithSig.SetSignature(generateSignature("sig", "key"))
full := new(object.GetHeaderPartFull) full := new(object.GetHeaderPartFull)
full.SetHeader(generateHeader(30)) full.SetHeaderWithSignature(hdrWithSig)
part = full part = full
} }

View file

@ -57,6 +57,12 @@ type Header struct {
split *SplitHeader split *SplitHeader
} }
type HeaderWithSignature struct {
header *Header
signature *refs.Signature
}
type Object struct { type Object struct {
objectID *refs.ObjectID objectID *refs.ObjectID
@ -136,7 +142,7 @@ type GetHeaderPart interface {
} }
type GetHeaderPartFull struct { type GetHeaderPartFull struct {
hdr *Header hdr *HeaderWithSignature
} }
type GetHeaderPartShort struct { 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 { func (o *Object) GetObjectID() *refs.ObjectID {
if o != nil { if o != nil {
return o.objectID 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 { if h != nil {
return h.hdr return h.hdr
} }
@ -1146,7 +1180,7 @@ func (h *GetHeaderPartFull) GetHeader() *Header {
return nil return nil
} }
func (h *GetHeaderPartFull) SetHeader(v *Header) { func (h *GetHeaderPartFull) SetHeaderWithSignature(v *HeaderWithSignature) {
if h != nil { if h != nil {
h.hdr = v h.hdr = v
} }