Exemplo n.º 1
0
func encodeLogEntry(entry *LogEntry) []byte {
	// Marshal log entry.
	entryData, err := proto.Marshal(entry)
	if err != nil {
		panic(fmt.Sprintf("unable to marshal log entry: %s", err))
	}
	// Encode the length of the data first, followed by the encoded data.
	data := encoding.EncodeUint32Ascending([]byte(nil), uint32(len(entryData)))
	return append(data, entryData...)
}
Exemplo n.º 2
0
func (v *Value) setChecksum(cksum uint32) {
	if len(v.RawBytes) >= checksumSize {
		encoding.EncodeUint32Ascending(v.RawBytes[:0], cksum)
	}
}