[#138] v2/object: Update to neofs-api jindo release
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
c0cc4a4374
commit
581cb2d2ba
6 changed files with 145 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue