func (csdb *CommitStateDB) Preimages() map[sdk.Hash][]byte {
	return csdb.preimages
}
Preimages returns a list of SHA3 preimages that have been submitted.
package types
import (
	"encoding/json"
	"fmt"
	"math/big"
	"sort"
	"sync"
	"github.com/tendermint/tendermint/crypto"
	"github.com/Dipper-Labs/Dipper-Protocol/app/v0/auth"
	"github.com/Dipper-Labs/Dipper-Protocol/app/v0/auth/types"
	"github.com/Dipper-Labs/Dipper-Protocol/app/v0/vm/common/math"
	"github.com/Dipper-Labs/Dipper-Protocol/hexutil"
	"github.com/Dipper-Labs/Dipper-Protocol/store/prefix"
	sdk "github.com/Dipper-Labs/Dipper-Protocol/types"
)
var (
	zeroBalance = sdk.ZeroInt().BigInt()
)
type revision struct {
	id           int
	journalIndex int
}
type CommitStateDB struct {
	ctx sdk.Context
	ak auth.AccountKeeper
	storageKey sdk.StoreKey
	stateObjects      map[string]*stateObject
	stateObjectsDirty map[string]struct{}
	refund uint64
	thash, bhash sdk.Hash
	txIndex      int
	logs         map[sdk.Hash][]*Log
	preimages map[sdk.Hash][]byte
	dbErr error
	journal        *journal
	validRevisions []revision
	nextRevisionID int
	lock sync.Mutex
}
func NewCommitStateDB(ak auth.AccountKeeper, storageKey sdk.StoreKey) *CommitStateDB {
	return &CommitStateDB{
		ak:                ak,
		storageKey:        storageKey,
		stateObjects:      make(map[string]*stateObject),
		stateObjectsDirty: make(map[string]struct{}),
		logs:              make(map[sdk.Hash][]*Log),
		preimages:         make(map[sdk.Hash][]byte),
		journal:           newJournal(),
	}
}
func NewStateDB(db *CommitStateDB) *CommitStateDB {
	return &CommitStateDB{
		ak:                db.ak,
		storageKey:        db.storageKey,
		stateObjects:      make(map[string]*stateObject),
		stateObjectsDirty: make(map[string]struct{}),
		logs:              make(map[sdk.Hash][]*Log),
		preimages:         make(map[sdk.Hash][]byte),
		journal:           newJournal(),
	}
}
func (csdb *CommitStateDB) WithContext(ctx sdk.Context) *CommitStateDB {
	csdb.ctx = ctx
	return csdb
}
func (csdb *CommitStateDB) ContractCreatedEvent(addr sdk.AccAddress) {
	csdb.ctx.EventManager().EmitEvents(sdk.Events{
		sdk.NewEvent(
			EventTypeContractCreated,
			sdk.NewAttribute(AttributeKeyAddress, addr.String()),
		),
	})
}
func (csdb *CommitStateDB) ContractCalledEvent(addr sdk.AccAddress) {
	csdb.ctx.EventManager().EmitEvents(sdk.Events{
		sdk.NewEvent(
			EventTypeContractCalled,
			sdk.NewAttribute(AttributeKeyAddress, addr.String()),
		),
	})
}
func (csdb *CommitStateDB) WithTxHash(txHash []byte) *CommitStateDB {
	csdb.thash = sdk.BytesToHash(txHash)
	return csdb
}
func (csdb *CommitStateDB) SetBalance(addr sdk.AccAddress, amount *big.Int) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.SetBalance(amount)
	}
}
func (csdb *CommitStateDB) AddBalance(addr sdk.AccAddress, amount *big.Int) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.AddBalance(amount)
	}
}
func (csdb *CommitStateDB) SubBalance(addr sdk.AccAddress, amount *big.Int) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.SubBalance(amount)
	}
}
func (csdb *CommitStateDB) SetNonce(addr sdk.AccAddress, nonce uint64) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.SetNonce(nonce)
	}
}
func (csdb *CommitStateDB) SetState(addr sdk.AccAddress, key, value sdk.Hash) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.SetState(key, value)
	}
}
func (csdb *CommitStateDB) SetCode(addr sdk.AccAddress, code []byte) {
	so := csdb.GetOrNewStateObject(addr)
	if so != nil {
		so.SetCode(sdk.BytesToHash(crypto.Sha256(code)), code)
	}
}
func (csdb *CommitStateDB) AddLog(log *Log) {
	csdb.journal.append(addLogChange{txhash: csdb.thash})
	log.TxHash = csdb.thash
	log.BlockHash = csdb.bhash
	log.TxIndex = uint(csdb.txIndex)
	log.Index = csdb.updateLogIndexByOne(false)
	csdb.logs[csdb.thash] = append(csdb.logs[csdb.thash], log)
}
func (csdb *CommitStateDB) AddPreimage(hash sdk.Hash, preimage []byte) {
	if _, ok := csdb.preimages[hash]; !ok {
		csdb.journal.append(addPreimageChange{hash: hash})
		pi := make([]byte, len(preimage))
		copy(pi, preimage)
		csdb.preimages[hash] = pi
	}
}