Backup & Rollback States for each function
2 methods to solve this
Method 1: Rollback
- Before executing the first line of code in a function, backup all state variable's values to backup variables
- Change nothing, allow function to change the state variables directly
- If a require statement fails
- Go to a rollback state
- Revert all state variables to the values in the backup variables
- Go to FunctionFailedEndState, then go to the LoopState
- if the function completes successfully, then go to FunctionSuccessEndState and then to the LoopState
Method 2: Commit
- Change the function to write to temporary state variables (similar to the backup variables)
- Copy the current state variables into the temporary variables
- If a require statement fails
- Go to FunctionFailedEndState, then go to the LoopState
- if the function completes successfully
- Go to the commit state
- Copy all temporary variables to the state variables
- Go to FunctionSuccessEndState and then to the LoopState
Edited by Jon Shahen