laconicd-deprecated/x/evm/statedb/config.go
yihuang ade84319e6
evm: refactor statedb implementation (#729)
* initial statedb module

unit tests

unit tests

keeper implementation

extract TxConfig

remove unused code

* keeper integration

* fix unit tests

* Apply suggestions from code review

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* fixup! initial statedb module

* changelog

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
2022-01-05 08:28:27 +01:00

33 lines
900 B
Go

package statedb
import "github.com/ethereum/go-ethereum/common"
// TxConfig encapulates the readonly information of current tx for `StateDB`.
type TxConfig struct {
BlockHash common.Hash // hash of current block
TxHash common.Hash // hash of current tx
TxIndex uint // the index of current transaction
LogIndex uint // the index of next log within current block
}
// NewTxConfig returns a TxConfig
func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig {
return TxConfig{
BlockHash: bhash,
TxHash: thash,
TxIndex: txIndex,
LogIndex: logIndex,
}
}
// NewEmptyTxConfig construct an empty TxConfig,
// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`.
func NewEmptyTxConfig(bhash common.Hash) TxConfig {
return TxConfig{
BlockHash: bhash,
TxHash: common.Hash{},
TxIndex: 0,
LogIndex: 0,
}
}