eth: properly flush files in standardTraceBlockToFile (#18502)

pull/18503/head
Martin Holst Swende 6 years ago committed by GitHub
parent 85a79b3ad3
commit 9bc0138ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      eth/api_tracer.go

@ -576,6 +576,7 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
vmConf vm.Config vmConf vm.Config
dump *os.File dump *os.File
writer *bufio.Writer
err error err error
) )
// If the transaction needs tracing, swap out the configs // If the transaction needs tracing, swap out the configs
@ -590,16 +591,19 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
dumps = append(dumps, dump.Name()) dumps = append(dumps, dump.Name())
// Swap out the noop logger to the standard tracer // Swap out the noop logger to the standard tracer
writer = bufio.NewWriter(dump)
vmConf = vm.Config{ vmConf = vm.Config{
Debug: true, Debug: true,
Tracer: vm.NewJSONLogger(&logConfig, bufio.NewWriter(dump)), Tracer: vm.NewJSONLogger(&logConfig, writer),
EnablePreimageRecording: true, EnablePreimageRecording: true,
} }
} }
// Execute the transaction and flush any traces to disk // Execute the transaction and flush any traces to disk
vmenv := vm.NewEVM(vmctx, statedb, api.config, vmConf) vmenv := vm.NewEVM(vmctx, statedb, api.config, vmConf)
_, _, _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())) _, _, _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()))
if writer != nil {
writer.Flush()
}
if dump != nil { if dump != nil {
dump.Close() dump.Close()
log.Info("Wrote standard trace", "file", dump.Name()) log.Info("Wrote standard trace", "file", dump.Name())

Loading…
Cancel
Save