func (s *SoVestDelegationWrap) getModifiedFields(oriTable *SoVestDelegation, curTable *SoVestDelegation) (map[string]bool, bool, error) {
	if oriTable == nil {
		return nil, false, errors.New("table info is nil, can't get modified fields")
	}
	hasWatcher := false
	fields := make(map[string]bool)
	if !reflect.DeepEqual(oriTable.Amount, curTable.Amount) {
		fields["Amount"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasAmountWatcher
	}
	if !reflect.DeepEqual(oriTable.CreatedBlock, curTable.CreatedBlock) {
		fields["CreatedBlock"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasCreatedBlockWatcher
	}
	if !reflect.DeepEqual(oriTable.Delivering, curTable.Delivering) {
		fields["Delivering"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasDeliveringWatcher
	}
	if !reflect.DeepEqual(oriTable.DeliveryBlock, curTable.DeliveryBlock) {
		fields["DeliveryBlock"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasDeliveryBlockWatcher
	}
	if !reflect.DeepEqual(oriTable.FromAccount, curTable.FromAccount) {
		fields["FromAccount"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasFromAccountWatcher
	}
	if !reflect.DeepEqual(oriTable.MaturityBlock, curTable.MaturityBlock) {
		fields["MaturityBlock"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasMaturityBlockWatcher
	}
	if !reflect.DeepEqual(oriTable.ToAccount, curTable.ToAccount) {
		fields["ToAccount"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasToAccountWatcher
	}
	hasWatcher = hasWatcher || s.watcherFlag.WholeWatcher
	return fields, hasWatcher, nil
}
Get all the modified fields in the table
package table
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"reflect"
	"sync"
	"github.com/coschain/contentos-go/common/encoding/kope"
	"github.com/coschain/contentos-go/iservices"
	prototype "github.com/coschain/contentos-go/prototype"
	proto "github.com/golang/protobuf/proto"
)
var (
	VestDelegationFromAccountTable   uint32 = 3132651932
	VestDelegationToAccountTable     uint32 = 3713114966
	VestDelegationMaturityBlockTable uint32 = 2354530309
	VestDelegationDeliveryBlockTable uint32 = 4292113245
	VestDelegationDeliveringTable    uint32 = 2725281102
	VestDelegationIdUniTable         uint32 = 4102010180
	VestDelegationIdRow uint32 = 2762572716
)
type SoVestDelegationWrap struct {
	dba         iservices.IDatabaseRW
	mainKey     *uint64
	watcherFlag *VestDelegationWatcherFlag
	mKeyFlag    int     
	mKeyBuf     []byte  
	mBuf        []byte  
	mdFuncMap   map[string]interface{}
}
func NewSoVestDelegationWrap(dba iservices.IDatabaseRW, key *uint64) *SoVestDelegationWrap {
	if dba == nil || key == nil {
		return nil
	}
	result := &SoVestDelegationWrap{dba, key, nil, -1, nil, nil, nil}
	result.initWatcherFlag()
	return result
}
func (s *SoVestDelegationWrap) CheckExist() bool {
	if s.dba == nil {
		return false
	}
	if s.mKeyFlag != -1 {
		if s.mKeyFlag == 0 {
			return false
		}
		return true
	}
	keyBuf, err := s.encodeMainKey()
	if err != nil {
		return false
	}
	res, err := s.dba.Has(keyBuf)
	if err != nil {
		return false
	}
	if res == false {
		s.mKeyFlag = 0
	} else {
		s.mKeyFlag = 1
	}
	return res
}
func (s *SoVestDelegationWrap) MustExist(errMsgs ...interface{}) *SoVestDelegationWrap {
	if !s.CheckExist() {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.MustExist: %v not found", s.mainKey), errMsgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) MustNotExist(errMsgs ...interface{}) *SoVestDelegationWrap {
	if s.CheckExist() {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.MustNotExist: %v already exists", s.mainKey), errMsgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) initWatcherFlag() {
	if s.watcherFlag == nil {
		s.watcherFlag = new(VestDelegationWatcherFlag)
		*(s.watcherFlag) = VestDelegationWatcherFlagOfDb(s.dba.ServiceId())
	}
}
func (s *SoVestDelegationWrap) create(f func(tInfo *SoVestDelegation)) error {
	if s.dba == nil {
		return errors.New("the db is nil")
	}
	if s.mainKey == nil {
		return errors.New("the main key is nil")
	}
	val := &SoVestDelegation{}
	f(val)
	if s.CheckExist() {
		return errors.New("the main key is already exist")
	}
	keyBuf, err := s.encodeMainKey()
	if err != nil {
		return err
	}
	buf, err := proto.Marshal(val)
	if err != nil {
		return err
	}
	err = s.dba.Put(keyBuf, buf)
	if err != nil {
		return err
	}
	if err = s.insertAllSortKeys(val); err != nil {
		s.delAllSortKeys(false, val)
		s.dba.Delete(keyBuf)
		return err
	}
	if sucNames, err := s.insertAllUniKeys(val); err != nil {
		s.delAllSortKeys(false, val)
		s.delUniKeysWithNames(sucNames, val)
		s.dba.Delete(keyBuf)
		return err
	}
	s.mKeyFlag = 1
	s.initWatcherFlag()
	if s.watcherFlag.AnyWatcher {
		ReportTableRecordInsert(s.dba.ServiceId(), s.dba.BranchId(), s.mainKey, val)
	}
	return nil
}
func (s *SoVestDelegationWrap) Create(f func(tInfo *SoVestDelegation), errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.create(f)
	if err != nil {
		panic(bindErrorInfo(fmt.Errorf("SoVestDelegationWrap.Create failed: %s", err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) getMainKeyBuf() ([]byte, error) {
	if s.mainKey == nil {
		return nil, errors.New("the main key is nil")
	}
	if s.mBuf == nil {
		var err error = nil
		s.mBuf, err = kope.Encode(s.mainKey)
		if err != nil {
			return nil, err
		}
	}
	return s.mBuf, nil
}
func (s *SoVestDelegationWrap) modify(f func(tInfo *SoVestDelegation)) error {
	if !s.CheckExist() {
		return errors.New("the SoVestDelegation table does not exist. Please create a table first")
	}
	oriTable := s.getVestDelegation()
	if oriTable == nil {
		return errors.New("fail to get origin table SoVestDelegation")
	}
	curTable := s.getVestDelegation()
	if curTable == nil {
		return errors.New("fail to create current table SoVestDelegation")
	}
	f(curTable)
	if !reflect.DeepEqual(curTable.Id, oriTable.Id) {
		return errors.New("primary key does not support modification")
	}
	s.initWatcherFlag()
	modifiedFields, hasWatcher, err := s.getModifiedFields(oriTable, curTable)
	if err != nil {
		return err
	}
	if modifiedFields == nil || len(modifiedFields) < 1 {
		return nil
	}
	err = s.checkSortAndUniFieldValidity(curTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeCheck, curTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeDel, oriTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.updateVestDelegation(curTable)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeInsert, curTable, modifiedFields)
	if err != nil {
		return err
	}
	if hasWatcher {
		ReportTableRecordUpdate(s.dba.ServiceId(), s.dba.BranchId(), s.mainKey, oriTable, curTable, modifiedFields)
	}
	return nil
}
func (s *SoVestDelegationWrap) Modify(f func(tInfo *SoVestDelegation), errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(f)
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.Modify failed: %s", err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetAmount(p *prototype.Vest, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.Amount = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetAmount( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetCreatedBlock(p uint64, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.CreatedBlock = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetCreatedBlock( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetDelivering(p bool, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.Delivering = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetDelivering( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetDeliveryBlock(p uint64, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.DeliveryBlock = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetDeliveryBlock( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetFromAccount(p *prototype.AccountName, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.FromAccount = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetFromAccount( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetMaturityBlock(p uint64, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.MaturityBlock = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetMaturityBlock( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) SetToAccount(p *prototype.AccountName, errArgs ...interface{}) *SoVestDelegationWrap {
	err := s.modify(func(r *SoVestDelegation) {
		r.ToAccount = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoVestDelegationWrap.SetToAccount( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoVestDelegationWrap) checkSortAndUniFieldValidity(curTable *SoVestDelegation, fields map[string]bool) error {
	if curTable != nil && fields != nil && len(fields) > 0 {
		if fields["FromAccount"] && curTable.FromAccount == nil {
			return errors.New("sort field FromAccount can't be modified to nil")
		}
		if fields["ToAccount"] && curTable.ToAccount == nil {
			return errors.New("sort field ToAccount can't be modified to nil")
		}
	}
	return nil
}