mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
Refactor context cancellation for EVM execution
This commit is contained in:
parent
777265620d
commit
51f73873f8
1 changed files with 1 additions and 4 deletions
|
|
@ -741,10 +741,7 @@ func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *s
|
||||||
func applyMessageWithEVM(ctx context.Context, evm *vm.EVM, msg *core.Message, timeout time.Duration, gp *core.GasPool) (*core.ExecutionResult, error) {
|
func applyMessageWithEVM(ctx context.Context, evm *vm.EVM, msg *core.Message, timeout time.Duration, gp *core.GasPool) (*core.ExecutionResult, error) {
|
||||||
// Wait for the context to be done and cancel the evm. Even if the
|
// Wait for the context to be done and cancel the evm. Even if the
|
||||||
// EVM has finished, cancelling may be done (repeatedly)
|
// EVM has finished, cancelling may be done (repeatedly)
|
||||||
go func() {
|
context.AfterFunc(ctx, evm.Cancel)
|
||||||
<-ctx.Done()
|
|
||||||
evm.Cancel()
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Execute the message.
|
// Execute the message.
|
||||||
result, err := core.ApplyMessage(evm, msg, gp)
|
result, err := core.ApplyMessage(evm, msg, gp)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue