mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
Improvements
This commit is contained in:
parent
2b92a78b48
commit
e76d9dc483
1 changed files with 8 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ package native
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
"sync/atomic"
|
||||
|
||||
|
|
@ -75,7 +76,7 @@ type prestateTracerConfig struct {
|
|||
DiffMode bool `json:"diffMode"` // If true, this tracer will return state modifications
|
||||
DisableCode bool `json:"disableCode"` // If true, this tracer will not return the contract code
|
||||
DisableStorage bool `json:"disableStorage"` // If true, this tracer will not return the contract storage
|
||||
EnableEmpty bool `json:"enableEmpty"` // If true, this tracer will return empty state objects
|
||||
IncludeEmpty bool `json:"includeEmpty"` // If true, this tracer will return empty state objects
|
||||
}
|
||||
|
||||
func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *params.ChainConfig) (*tracers.Tracer, error) {
|
||||
|
|
@ -83,6 +84,11 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p
|
|||
if err := json.Unmarshal(cfg, &config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Diff mode has special semantics around account creating and deletion which
|
||||
// requires it to include empty accounts and storage.
|
||||
if config.DiffMode && config.IncludeEmpty {
|
||||
return nil, errors.New("cannot use diffMode with includeEmpty")
|
||||
}
|
||||
t := &prestateTracer{
|
||||
pre: stateMap{},
|
||||
post: stateMap{},
|
||||
|
|
@ -181,7 +187,7 @@ func (t *prestateTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
|||
// the new created contracts' prestate were empty, so delete them
|
||||
for a := range t.created {
|
||||
// the created contract maybe exists in statedb before the creating tx
|
||||
if s := t.pre[a]; s != nil && s.empty && !t.config.EnableEmpty {
|
||||
if s := t.pre[a]; s != nil && s.empty && !t.config.IncludeEmpty {
|
||||
delete(t.pre, a)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue