[#229] v2/object: Add hash fields to ShortHeader message

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-17 13:18:07 +03:00
parent b2528d4c59
commit 8fe135ab8c
5 changed files with 81 additions and 1 deletions

View file

@ -12,6 +12,8 @@ const (
shortHdrOwnerField = 3
shortHdrObjectTypeField = 4
shortHdrPayloadLength = 5
shortHdrHashField = 6
shortHdrHomoHashField = 7
attributeKeyField = 1
attributeValueField = 2
@ -151,7 +153,21 @@ func (h *ShortHeader) StableMarshal(buf []byte) ([]byte, error) {
offset += n
_, err = proto.UInt64Marshal(shortHdrPayloadLength, buf[offset:], h.payloadLen)
n, err = proto.UInt64Marshal(shortHdrPayloadLength, buf[offset:], h.payloadLen)
if err != nil {
return nil, err
}
offset += n
n, err = proto.NestedStructureMarshal(shortHdrHashField, buf[offset:], h.payloadHash)
if err != nil {
return nil, err
}
offset += n
n, err = proto.NestedStructureMarshal(shortHdrHomoHashField, buf[offset:], h.homoHash)
if err != nil {
return nil, err
}
@ -169,6 +185,8 @@ func (h *ShortHeader) StableSize() (size int) {
size += proto.NestedStructureSize(shortHdrOwnerField, h.ownerID)
size += proto.EnumSize(shortHdrObjectTypeField, int32(h.typ))
size += proto.UInt64Size(shortHdrPayloadLength, h.payloadLen)
size += proto.NestedStructureSize(shortHdrHashField, h.payloadHash)
size += proto.NestedStructureSize(shortHdrHomoHashField, h.homoHash)
return size
}