Esempio n. 1
0
func (v Value) checksum() uint32 {
	if len(v.RawBytes) < checksumSize {
		return 0
	}
	_, u, err := encoding.DecodeUint32Ascending(v.RawBytes[:checksumSize])
	if err != nil {
		panic(err)
	}
	return u
}
Esempio n. 2
0
// Decode decodes the next log entry into the provided protobuf message.
func (lr *EntryDecoder) Decode(entry *LogEntry) error {
	// Read the next log entry.
	szBuf := make([]byte, 4)
	n, err := lr.in.Read(szBuf)
	if err != nil {
		return err
	}
	_, sz, err := encoding.DecodeUint32Ascending(szBuf)
	if err != nil {
		return err
	}
	buf := make([]byte, sz)
	n, err = lr.in.Read(buf)
	if err != nil {
		return err
	}
	if err := proto.Unmarshal(buf[:n], entry); err != nil {
		return err
	}
	return nil
}