eth: more elegant api_tracer

This commit is contained in:
Martin Holst Swende 2018-10-03 16:02:45 +02:00
parent 4727670df7
commit f616a39b6a
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -394,9 +394,8 @@ func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string,
// TraceBadBlock returns the structured logs created during the execution of a block
// within the blockchain 'badblocks' cache
func (api *PrivateDebugAPI) TraceBadBlock(ctx context.Context, index int, config *TraceConfig) ([]*txTraceResult, error) {
badBlocks := api.eth.blockchain.BadBlocks()
if l := len(badBlocks); index < l {
return api.traceBlock(ctx, badBlocks[index], config)
if blocks := api.eth.blockchain.BadBlocks(); index < len(blocks) {
return api.traceBlock(ctx, blocks[index], config)
}
return nil, fmt.Errorf("index out of range")
}