Commit 86f78933 authored by obscuren's avatar obscuren

Moved state reset to defered function

parent febec5ca
......@@ -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(&ethstate.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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment