// Commit writes the state to the underlying in-memory trie database.
Commit writes the state to the underlying in-memory trie database.
// Commit writes the state to the underlying in - memory trie database .
func (shard *StateDBManage) Commit(deleteEmptyObjects bool) ([]common.CoinRoot, []common.Coinbyte, error) {
	var coinbytes = make([]common.Coinbyte, 0)
	for _, cm := range shard.shardings {
		var roots = make([]common.Hash, 0, 256)
		for _, rm := range cm.Rmanage {
			root, err := rm.State.Commit(deleteEmptyObjects)
			if err != nil {
				log.Error("file:sharding_statedb.go", "func:Commit", err)
				panic(err)
			}
			roots = append(roots, root)
		}
		bs, bshash := types.RlpEncodeAndHash(roots)
		err := shard.mdb.Put(bshash[:], bs)
		if err != nil {
			log.Error("file:sharding_statedb.go", "func:Commit", err)
			panic(err)
		}
		isex := false
		for i, croot := range shard.retcoinRoot {
			if croot.Cointyp == cm.Cointyp {
				shard.retcoinRoot[i].Root = bshash
				shard.retcoinRoot[i].TxHash = types.EmptyRootHash
				shard.retcoinRoot[i].ReceiptHash = types.EmptyRootHash
				isex = true
				break
			}
		}
		if !isex {
			shard.retcoinRoot = append(shard.retcoinRoot, common.CoinRoot{Cointyp: cm.Cointyp, Root: bshash, TxHash: types.EmptyRootHash, ReceiptHash: types.EmptyRootHash})
		}
		coinbytes = append(coinbytes, common.Coinbyte{Root: bshash, Byte256: roots})
	}
	return shard.retcoinRoot, coinbytes, nil
}
func ( shard * StateDBManage ) Commit ( deleteEmptyObjects bool ) ( [ ] common . CoinRoot , [ ] common . Coinbyte , error ) { var coinbytes = make ( [ ] common . Coinbyte , 0 ) for _ , cm := range shard . shardings { var roots = make ( [ ] common . Hash , 0 , 256 ) for _ , rm := range cm . Rmanage { root , err := rm . State . Commit ( deleteEmptyObjects ) if err != nil { log . Error ( " " , " " , err ) panic ( err ) } roots = append ( roots , root ) } bs , bshash := types . RlpEncodeAndHash ( roots ) err := shard . mdb . Put ( bshash [ : ] , bs ) if err != nil { log . Error ( " " , " " , err ) panic ( err ) } isex := false for i , croot := range shard . retcoinRoot { if croot . Cointyp == cm . Cointyp { shard . retcoinRoot [ i ] . Root = bshash shard . retcoinRoot [ i ] . TxHash = types . EmptyRootHash shard . retcoinRoot [ i ] . ReceiptHash = types . EmptyRootHash isex = true break } } if ! isex { shard . retcoinRoot = append ( shard . retcoinRoot , common . CoinRoot { Cointyp : cm . Cointyp , Root : bshash , TxHash : types . EmptyRootHash , ReceiptHash : types . EmptyRootHash } ) } coinbytes = append ( coinbytes , common . Coinbyte { Root : bshash , Byte256 : roots } ) } return shard . retcoinRoot , coinbytes , nil }
Commit writes the state to the underlying in-memory trie database.
Commit writes the state to the underlying in - memory trie database .
//		bshash := types.RlpHash(roots) //		bs, err := rlp.EncodeToBytes(roots)