EncodeHashMeta encodes a HashMetadata and returns the byte array and length. +-------------+------------+------------+------------+---------+----------+----------+---------+---------+ | data type | data size | expire | version | counter | created | updated | field | value | +--------
()
| 1501 | // | 1 byte | variable | variable | variable | variable| variable | variable | variable| variable| |
| 1502 | // +-------------+------------+------------+------------+---------+----------+----------+---------+---------+ |
| 1503 | func (meta *HashMetadata) encodeHashMeta() []byte { |
| 1504 | buf := make([]byte, maxHashMetaSize) |
| 1505 | |
| 1506 | // Store the data type at the first byte |
| 1507 | buf[0] = meta.dataType |
| 1508 | |
| 1509 | var offset = 1 |
| 1510 | |
| 1511 | // Store the lengths of data size, expire, version, counter, createdTime and lastUpdatedTime |
| 1512 | offset += binary.PutVarint(buf[offset:], meta.dataSize) |
| 1513 | offset += binary.PutVarint(buf[offset:], meta.expire) |
| 1514 | offset += binary.PutVarint(buf[offset:], meta.version) |
| 1515 | offset += binary.PutVarint(buf[offset:], meta.counter) |
| 1516 | offset += binary.PutVarint(buf[offset:], meta.createdTime) |
| 1517 | offset += binary.PutVarint(buf[offset:], meta.lastUpdatedTime) |
| 1518 | return buf[:offset] |
| 1519 | } |
| 1520 | |
| 1521 | // DecodeHashMeta decodes the HashMetadata from a byte buffer. |
| 1522 | func decodeHashMeta(buf []byte) *HashMetadata { |