mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
cmd/evm/internal/t8ntool: polish the code
This commit is contained in:
parent
b96132b8db
commit
5e73c2be93
4 changed files with 11 additions and 17 deletions
|
|
@ -127,8 +127,7 @@ type rejectedTx struct {
|
|||
}
|
||||
|
||||
// Apply applies a set of transactions to a pre-state
|
||||
func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||
txIt txIterator, miningReward int64) (*state.StateDB, *ExecutionResult, []byte, error) {
|
||||
func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, txIt txIterator, miningReward int64) (*state.StateDB, *ExecutionResult, []byte, error) {
|
||||
// Capture errors for BLOCKHASH operation, if we haven't been supplied the
|
||||
// required blockhashes
|
||||
var hashError error
|
||||
|
|
|
|||
|
|
@ -82,16 +82,16 @@ func newResultWriter(baseDir string, tracer *tracers.Tracer) *tracing.Hooks {
|
|||
// OnTxStart creates a new output-file specific for this transaction, and invokes
|
||||
// the inner OnTxStart handler.
|
||||
func (l *fileWritingTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||
// Open a new file,
|
||||
// Open a new file, or print a warning log if it's failed
|
||||
fname := filepath.Join(l.baseDir, fmt.Sprintf("trace-%d-%v.%v", l.txIndex, tx.Hash().String(), l.suffix))
|
||||
traceFile, err := os.Create(fname)
|
||||
if err != nil {
|
||||
log.Warn("Failed creating trace-file", "err", err)
|
||||
}
|
||||
} else {
|
||||
log.Info("Created tracing-file", "path", fname)
|
||||
l.destination = traceFile
|
||||
|
||||
if l.inner.OnTxStart != nil {
|
||||
}
|
||||
if l.inner != nil && l.inner.OnTxStart != nil {
|
||||
l.inner.OnTxStart(env, tx, from)
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ func (l *fileWritingTracer) OnTxStart(env *tracing.VMContext, tx *types.Transact
|
|||
// OnTxEnd writes result (if getResult exist), closes any currently open output-file,
|
||||
// and invokes the inner OnTxEnd handler.
|
||||
func (l *fileWritingTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||
if l.inner.OnTxEnd != nil {
|
||||
if l.inner != nil && l.inner.OnTxEnd != nil {
|
||||
l.inner.OnTxEnd(receipt, err)
|
||||
}
|
||||
if l.getResult != nil && l.destination != nil {
|
||||
|
|
@ -129,7 +129,7 @@ func (l *fileWritingTracer) hooks() *tracing.Hooks {
|
|||
}
|
||||
},
|
||||
OnOpcode: func(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||
if l.inner.OnOpcode != nil {
|
||||
if l.inner != nil && l.inner.OnOpcode != nil {
|
||||
l.inner.OnOpcode(pc, op, gas, cost, scope, rData, depth, err)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,12 +64,10 @@ func (r *result) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
func Transaction(ctx *cli.Context) error {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
// We need to load the transactions. May be either in stdin input or in files.
|
||||
// Check if anything needs to be read from stdin
|
||||
var (
|
||||
err error
|
||||
txStr = ctx.String(InputTxsFlag.Name)
|
||||
inputData = &input{}
|
||||
chainConfig *params.ChainConfig
|
||||
|
|
@ -82,6 +80,7 @@ func Transaction(ctx *cli.Context) error {
|
|||
}
|
||||
// Set the chain id
|
||||
chainConfig.ChainID = big.NewInt(ctx.Int64(ChainIDFlag.Name))
|
||||
|
||||
var body hexutil.Bytes
|
||||
if txStr == stdinSelector {
|
||||
decoder := json.NewDecoder(os.Stdin)
|
||||
|
|
@ -107,6 +106,7 @@ func Transaction(ctx *cli.Context) error {
|
|||
}
|
||||
}
|
||||
signer := types.MakeSigner(chainConfig, new(big.Int), 0)
|
||||
|
||||
// We now have the transactions in 'body', which is supposed to be an
|
||||
// rlp list of transactions
|
||||
it, err := rlp.NewListIterator([]byte(body))
|
||||
|
|
|
|||
|
|
@ -133,11 +133,6 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon
|
|||
return evm
|
||||
}
|
||||
|
||||
// SetTracer sets the tracer for following state transition.
|
||||
func (evm *EVM) SetTracer(tracer *tracing.Hooks) {
|
||||
evm.Config.Tracer = tracer
|
||||
}
|
||||
|
||||
// SetPrecompiles sets the precompiled contracts for the EVM.
|
||||
// This method is only used through RPC calls.
|
||||
// It is not thread-safe.
|
||||
|
|
|
|||
Loading…
Reference in a new issue