// Copy creates a deep, independent copy of the state.
// Snapshots of the copied state cannot be applied to the copy.
Copy creates a deep, independent copy of the state.
Snapshots of the copied state cannot be applied to the copy.
// Copy creates a deep independent copy of the state . // Snapshots of the copied state cannot be applied to the copy .
func (shard *StateDBManage) Copy() *StateDBManage {
	state := &StateDBManage{
		db:        shard.db,
		mdb:       shard.mdb,
		shardings: make([]*CoinManage, 0),
		coinRoot:  make([]common.CoinRoot, 0),
	}
	for _, cm := range shard.shardings {
		rms := make([]*RangeManage, 0, 256)
		for _, rm := range cm.Rmanage {
			sd := rm.State.Copy()
			rms = append(rms, &RangeManage{
				Range: rm.Range,
				State: sd,
			})
		}
		state.shardings = append(state.shardings, &CoinManage{
			Cointyp: cm.Cointyp,
			Rmanage: rms,
		})
	}
	for _, root := range shard.coinRoot {
		state.coinRoot = append(state.coinRoot, common.CoinRoot{
			Root:    root.Root,
			Cointyp: root.Cointyp,
		})
	}
	return state
}
func ( shard * StateDBManage ) Copy ( ) * StateDBManage { state := & StateDBManage { db : shard . db , mdb : shard . mdb , shardings : make ( [ ] * CoinManage , 0 ) , coinRoot : make ( [ ] common . CoinRoot , 0 ) , } for _ , cm := range shard . shardings { rms := make ( [ ] * RangeManage , 0 , 256 ) for _ , rm := range cm . Rmanage { sd := rm . State . Copy ( ) rms = append ( rms , & RangeManage { Range : rm . Range , State : sd , } ) } state . shardings = append ( state . shardings , & CoinManage { Cointyp : cm . Cointyp , Rmanage : rms , } ) } for _ , root := range shard . coinRoot { state . coinRoot = append ( state . coinRoot , common . CoinRoot { Root : root . Root , Cointyp : root . Cointyp , } ) } return state }
Copy creates a deep, independent copy of the state.
Copy creates a deep independent copy of the state .