diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-07-04 01:54:14 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-07-04 15:27:42 +0800 |
commit | 0f04af5916cba5234118a442b6100c8122389abf (patch) | |
tree | 5941123c1c1ad743d2e4e231481fdb93d005224c /core/vm | |
parent | 9c3db1be1dd24c366a58a7ced22adfa0b0839efe (diff) | |
download | go-tangerine-0f04af5916cba5234118a442b6100c8122389abf.tar.gz go-tangerine-0f04af5916cba5234118a442b6100c8122389abf.tar.zst go-tangerine-0f04af5916cba5234118a442b6100c8122389abf.zip |
Fix core error forwarding, unify OOG VM err
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/errors.go | 24 | ||||
-rw-r--r-- | core/vm/vm.go | 4 |
2 files changed, 5 insertions, 23 deletions
diff --git a/core/vm/errors.go b/core/vm/errors.go index 799eb6797..75b9c0f10 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -1,21 +1,14 @@ package vm import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/params" ) -type OutOfGasError struct{} - -func (self OutOfGasError) Error() string { - return "Out Of Gas" -} - -func IsOOGErr(err error) bool { - _, ok := err.(OutOfGasError) - return ok -} +var OutOfGasError = errors.New("Out of gas") +var DepthError = fmt.Errorf("Max call depth exceeded (%d)", params.CallCreateDepth) type StackError struct { req, has int @@ -33,14 +26,3 @@ func IsStack(err error) bool { _, ok := err.(StackError) return ok } - -type DepthError struct{} - -func (self DepthError) Error() string { - return fmt.Sprintf("Max call depth exceeded (%d)", params.CallCreateDepth) -} - -func IsDepthErr(err error) bool { - _, ok := err.(DepthError) - return ok -} diff --git a/core/vm/vm.go b/core/vm/vm.go index ba803683b..e390fb89c 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -116,7 +116,7 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) { context.UseGas(context.Gas) - return context.Return(nil), OutOfGasError{} + return context.Return(nil), OutOfGasError } // Resize the memory calculated previously mem.Resize(newMemSize.Uint64()) @@ -789,7 +789,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, input []byte, context *Con return context.Return(ret), nil } else { - return nil, OutOfGasError{} + return nil, OutOfGasError } } |