Example #1
0
func (l *themisLock) parse(r iohelper.ByteMultiReader) error {
	// read type
	var typ uint8
	err := binary.Read(r, binary.BigEndian, &typ)
	if err != nil {
		return errors.Trace(err)
	}
	l.typ = hbase.Type(typ)

	// read ts
	var ts int64
	err = binary.Read(r, binary.BigEndian, &ts)
	if err != nil {
		return errors.Trace(err)
	}
	l.ts = uint64(ts)

	// read client addr
	sz, err := binary.ReadUvarint(r)
	if err != nil {
		return errors.Trace(err)
	}
	addr := make([]byte, sz)
	r.Read(addr)
	l.clientAddr = string(addr)

	// read wall time
	var wallTs int64
	err = binary.Read(r, binary.BigEndian, &wallTs)
	if err != nil {
		return errors.Trace(err)
	}
	l.wallTs = uint64(wallTs)
	return nil
}
Example #2
0
func (l *themisPrimaryLock) parse(buf iohelper.ByteMultiReader) error {
	l.themisLock.parse(buf)
	var sz int32
	err := binary.Read(buf, binary.BigEndian, &sz)
	if err != nil {
		return errors.Trace(err)
	}
	for i := 0; i < int(sz); i++ {
		c := &hbase.ColumnCoordinate{}
		c.ParseField(buf)
		b, err := buf.ReadByte()
		if err != nil {
			return errors.Trace(err)
		}
		t := hbase.Type(b)
		l.addSecondary(c, t)
	}
	return nil
}