Пример #1
0
// Epoch returns the current mutation epoch of the volume.
//
// Returned value is valid after the transaction.
func (v *Volume) Epoch() (clock.Epoch, error) {
	val := v.b.Get(volumeStateEpoch)
	var epoch clock.Epoch
	if err := epoch.UnmarshalBinary(val); err != nil {
		return 0, err
	}
	return epoch, nil
}
Пример #2
0
func (v *Volume) setEpoch(epoch clock.Epoch) error {
	buf, err := epoch.MarshalBinary()
	if err != nil {
		return err
	}
	if err := v.b.Put(volumeStateEpoch, buf); err != nil {
		return err
	}
	return nil
}