[tracer] fix bug of nil reference

pull/3818/head
peekpi 3 years ago
parent 9a3ab9fcaa
commit e86282408d
  1. 2
      api/service/explorer/storage.go
  2. 6
      core/blockchain.go
  3. 1
      core/events.go
  4. 6
      hmy/tracers/block_tracer.go

@ -305,7 +305,9 @@ LOOP:
} }
traceResult.btc = bc.db.NewBatch() traceResult.btc = bc.db.NewBatch()
traceResult.data.ToDB(func(key, value []byte) { traceResult.data.ToDB(func(key, value []byte) {
if exist, err := isTraceResultInDB(bc.db, key); !exist && err == nil {
_ = writeTraceResult(traceResult.btc, key, value) _ = writeTraceResult(traceResult.btc, key, value)
}
}) })
select { select {
case bc.resultT <- traceResult: case bc.resultT <- traceResult:

@ -1453,8 +1453,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifyHeaders bool) (int,
vmConfig := bc.vmConfig vmConfig := bc.vmConfig
if bc.trace { if bc.trace {
ev := TraceEvent{ ev := TraceEvent{
Block: block, Tracer: &tracers.ParityBlockTracer{
Tracer: &tracers.ParityBlockTracer{}, Hash: block.Hash(),
Number: block.NumberU64(),
},
} }
vmConfig = vm.Config{ vmConfig = vm.Config{
Debug: true, Debug: true,

@ -44,7 +44,6 @@ type ChainEvent struct {
} }
type TraceEvent struct { type TraceEvent struct {
Block *types.Block
Tracer *tracers.ParityBlockTracer Tracer *tracers.ParityBlockTracer
} }

@ -203,6 +203,8 @@ type ParityTxTracer struct {
action action
} }
type ParityBlockTracer struct { type ParityBlockTracer struct {
Hash common.Hash
Number uint64
cur *ParityTxTracer cur *ParityTxTracer
tracers []*ParityTxTracer tracers []*ParityTxTracer
} }
@ -401,8 +403,8 @@ func (jst *ParityBlockTracer) CaptureEnd(output []byte, gasUsed uint64, t time.D
func (jst *ParityBlockTracer) GetStorage() *TraceBlockStorage { func (jst *ParityBlockTracer) GetStorage() *TraceBlockStorage {
blockStorage := &TraceBlockStorage{ blockStorage := &TraceBlockStorage{
Hash: jst.cur.blockHash, Hash: jst.Hash,
Number: jst.cur.blockNumber, Number: jst.Number,
addressIndex: make(map[common.Address]int), addressIndex: make(map[common.Address]int),
dataIndex: make(map[common.Hash]int), dataIndex: make(map[common.Hash]int),
} }

Loading…
Cancel
Save