chengxilo commented on code in PR #1904:
URL: https://github.com/apache/iggy/pull/1904#discussion_r2164124710


##########
foreign/go/contracts/message_header.go:
##########
@@ -21,23 +21,21 @@ import (
        "encoding/binary"
        "errors"
        "time"
-
-       "github.com/google/uuid"
 )
 
 const MessageHeaderSize = 8 + 16 + 8 + 8 + 8 + 4 + 4
 
 type MessageHeader struct {
-       Checksum         uint64    `json:"checksum"`
-       Id               uuid.UUID `json:"id"`
-       Offset           uint64    `json:"offset"`
-       Timestamp        uint64    `json:"timestamp"`
-       OriginTimestamp  uint64    `json:"origin_timestamp"`
-       UserHeaderLength uint32    `json:"user_header_length"`
-       PayloadLength    uint32    `json:"payload_length"`
+       Checksum         uint64   `json:"checksum"`
+       Id               [16]byte `json:"id"`

Review Comment:
   Btw, for your FromBytes advice we can also your a MessageID() to do the 
convert, here is the code:
   ```golang
   func MessageHeaderFromBytes(data []byte) (*MessageHeader, error) {
   
        if len(data) != MessageHeaderSize {
                return nil, errors.New("data has incorrect size, must be 56")
        }
        checksum := binary.LittleEndian.Uint64(data[0:8])
        id := data[8:24]
        timestamp := binary.LittleEndian.Uint64(data[24:32])
        originTimestamp := binary.LittleEndian.Uint64(data[32:40])
        offset := binary.LittleEndian.Uint64(data[40:48])
        userHeaderLength := binary.LittleEndian.Uint32(data[48:52])
        payloadLength := binary.LittleEndian.Uint32(data[52:56])
   
        return &MessageHeader{
                Checksum:         checksum,
                Id:               MessageID(id),
                Offset:           offset,
                Timestamp:        timestamp,
                OriginTimestamp:  originTimestamp,
                UserHeaderLength: userHeaderLength,
                PayloadLength:    payloadLength,
        }, nil
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to