// Roll back live to the specified checkpoint and return possible errors
// It can succeed only when the value of checkpoint matches the value of root hash with that in
// the record. Otherwise, the failure reason is returned
Roll back live to the specified checkpoint and return possible errors
It can succeed only when the value of checkpoint matches the value of root hash with that in
the record. Otherwise, the failure reason is returned
// Roll back live to the specified checkpoint and return possible errors // It can succeed only when the value of checkpoint matches the value of root hash with that in // the record . Otherwise the failure reason is returned
func (r *RevertableTrie) RevertTo(checkPoint int, root []byte) error {
	if checkPoint < 0 || len(root) == 0 {
		return common.ErrNil
	}
	r.lock.Lock()
	defer r.lock.Unlock()
	if checkPoint >= len(r.chkpts) {
		return common.ErrNotFound
	}
	h := common.BytesToHash(root)
	if h != r.chkpts[checkPoint] {
		return ErrNotExist
	}
	r.chkpts = r.chkpts[:checkPoint]
	if len(r.chkpts) == 0 {
		r.chkpts = nil
		r.Live = nil
	} else {
		r.Live = r.Live.Inherit(root)
	}
	return nil
}
func ( r * RevertableTrie ) RevertTo ( checkPoint int , root [ ] byte ) error { if checkPoint < 0 || len ( root ) == 0 { return common . ErrNil } r . lock . Lock ( ) defer r . lock . Unlock ( ) if checkPoint >= len ( r . chkpts ) { return common . ErrNotFound } h := common . BytesToHash ( root ) if h != r . chkpts [ checkPoint ] { return ErrNotExist } r . chkpts = r . chkpts [ : checkPoint ] if len ( r . chkpts ) == 0 { r . chkpts = nil r . Live = nil } else { r . Live = r . Live . Inherit ( root ) } return nil }
Roll back live to the specified checkpoint and return possible errors
It can succeed only when the value of checkpoint matches the value of root hash with that in
the record.
Roll back live to the specified checkpoint and return possible errors It can succeed only when the value of checkpoint matches the value of root hash with that in the record .