diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-16 19:39:30 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-16 19:39:30 +0800 |
commit | 86f789333a7c509058412c8a7253117af74488cd (patch) | |
tree | aeb87bc8f5ef583c152b5992a5d64a5c8b9cdfb0 | |
parent | febec5ca4a059a3e3a5cc2b5fe0d14ba02492b95 (diff) | |
download | dexon-86f789333a7c509058412c8a7253117af74488cd.tar.gz dexon-86f789333a7c509058412c8a7253117af74488cd.tar.zst dexon-86f789333a7c509058412c8a7253117af74488cd.zip |
Moved state reset to defered function
-rw-r--r-- | ethvm/execution.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ethvm/execution.go b/ethvm/execution.go index 0550a8bf3..ce90ade15 100644 --- a/ethvm/execution.go +++ b/ethvm/execution.go @@ -28,6 +28,11 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err env := self.vm.Env() snapshot := env.State().Copy() + defer func() { + if err != nil { + env.State().Set(snapshot) + } + }() msg := env.State().Manifest().AddMessage(ðstate.Message{ To: self.address, From: caller.Address(), @@ -49,7 +54,7 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err caller.Object().SubAmount(self.value) stateObject.AddAmount(self.value) - // Precompiled contracts (address.go) 1, 2 & 3. + // Pre-compiled contracts (address.go) 1, 2 & 3. naddr := ethutil.BigD(codeAddr).Uint64() if p := Precompiled[naddr]; p != nil { if self.gas.Cmp(p.Gas) >= 0 { @@ -74,9 +79,5 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err } } - if err != nil { - env.State().Set(snapshot) - } - return } |