mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
Add canceler interface
This commit is contained in:
parent
fc35780124
commit
f434c8df56
3 changed files with 11 additions and 3 deletions
|
|
@ -565,5 +565,6 @@ func (evm *EVM) GetVMContext() *live.VMContext {
|
|||
GasPrice: evm.TxContext.GasPrice,
|
||||
ChainConfig: evm.ChainConfig(),
|
||||
StateDB: evm.StateDB,
|
||||
VM: evm,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ type StateDB interface {
|
|||
GetRefund() uint64
|
||||
}
|
||||
|
||||
// Canceler is an interface that wraps the Cancel method.
|
||||
// It allows loggers to cancel EVM processing.
|
||||
type Canceler interface {
|
||||
Cancel()
|
||||
}
|
||||
|
||||
type VMContext struct {
|
||||
Coinbase common.Address
|
||||
BlockNumber *big.Int
|
||||
|
|
@ -38,6 +44,7 @@ type VMContext struct {
|
|||
GasPrice *big.Int
|
||||
ChainConfig *params.ChainConfig
|
||||
StateDB StateDB
|
||||
VM Canceler
|
||||
}
|
||||
|
||||
// BlockEvent is emitted upon tracing an incoming block.
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ func (t *jsTracer) CaptureTxStart(env *live.VMContext, tx *types.Transaction, fr
|
|||
gasPriceBig, err := t.toBig(t.vm, env.GasPrice.String())
|
||||
if err != nil {
|
||||
t.err = err
|
||||
t.env.Cancel()
|
||||
t.env.VM.Cancel()
|
||||
return
|
||||
}
|
||||
t.ctx["gasPrice"] = gasPriceBig
|
||||
|
|
@ -275,7 +275,7 @@ func (t *jsTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
|||
func (t *jsTracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
cancel := func(err error) {
|
||||
t.err = err
|
||||
t.env.Cancel()
|
||||
t.env.VM.Cancel()
|
||||
}
|
||||
if create {
|
||||
t.ctx["type"] = t.vm.ToValue("CREATE")
|
||||
|
|
@ -424,7 +424,7 @@ func (t *jsTracer) onError(context string, err error) {
|
|||
t.err = wrapError(context, err)
|
||||
// `env` is set on CaptureStart which comes before any JS execution.
|
||||
// So it should be non-nil.
|
||||
t.env.Cancel()
|
||||
t.env.VM.Cancel()
|
||||
}
|
||||
|
||||
func wrapError(context string, err error) error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue