core/vm: rework reversion to work on a higher level

This commit is contained in:
Péter Szilágyi
2017-08-16 17:09:29 +03:00
parent b70a73cd3e
commit f9fb70d2ee
6 changed files with 58 additions and 50 deletions

View File

@@ -209,24 +209,22 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
if verifyPool {
verifyIntegerPool(in.intPool)
}
// checks whether the operation should revert state.
if operation.reverts {
in.evm.StateDB.RevertToSnapshot(snapshot)
}
switch {
case err != nil:
return nil, err
case operation.halts:
return res, nil
case !operation.jumps:
pc++
}
// if the operation clears the return data (e.g. it has returning data)
// set the last return to the result of the operation.
if operation.returns {
in.returnData = res
}
switch {
case err != nil:
return nil, err
case operation.reverts:
return res, errExecutionReverted
case operation.halts:
return res, nil
case !operation.jumps:
pc++
}
}
return nil, nil
}