mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
internal/ethapi: reuse headers list for simulate
This commit is contained in:
parent
3a01c3a230
commit
1cf96f6e12
1 changed files with 3 additions and 7 deletions
|
|
@ -138,20 +138,16 @@ func (sim *simulator) execute(ctx context.Context, blocks []simBlock) ([]*simBlo
|
|||
}
|
||||
var (
|
||||
results = make([]*simBlockResult, len(blocks))
|
||||
// prevHeaders is the header for all previously simulated blocks.
|
||||
// It is "filled" compared to the barebone header available prior to execution.
|
||||
// It will be used for serving the BLOCKHASH opcode.
|
||||
prevHeaders = make([]*types.Header, 0, len(blocks))
|
||||
parent = sim.base
|
||||
)
|
||||
for bi, block := range blocks {
|
||||
result, callResults, err := sim.processBlock(ctx, &block, headers[bi], parent, prevHeaders, timeout)
|
||||
result, callResults, err := sim.processBlock(ctx, &block, headers[bi], parent, headers[:bi], timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headers[bi] = result.Header()
|
||||
results[bi] = &simBlockResult{fullTx: sim.fullTx, chainConfig: sim.chainConfig, Block: result, Calls: callResults}
|
||||
parent = result.Header()
|
||||
prevHeaders = append(prevHeaders, parent)
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue