Resumer can be passed as an option to Validate. It acts like StopAfterFinalize, but additionally writes a function to the given pointer that can be used to pick up execution after the finalize step. This function can be called only once, since calling it will affect the VM state.
(f *func(rest []byte) error)
| 82 | // finalize step. This function can be called only once, since |
| 83 | // calling it will affect the VM state. |
| 84 | func Resumer(f *func(rest []byte) error) Option { |
| 85 | var called bool |
| 86 | return Option{ |
| 87 | apply: func(vm *VM) { |
| 88 | vm.stopAfterFinalize = true |
| 89 | *f = func(rest []byte) (err error) { |
| 90 | if called { |
| 91 | return errors.New("resumer function called twice") |
| 92 | } |
| 93 | called = true |
| 94 | |
| 95 | defer vm.recoverError(&err) |
| 96 | vm.stopAfterFinalize = false |
| 97 | vm.exec(rest) |
| 98 | if !vm.contract.stack.isEmpty() || !vm.argstack.isEmpty() { |
| 99 | return vm.wraperr(ErrResidue) |
| 100 | } |
| 101 | vm.runHooks(vm.onExit) |
| 102 | return nil |
| 103 | } |
| 104 | }, |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // Trace can be passed as an option to Validate. It causes a textual |
| 109 | // execution trace to be written to the given io.Writer. |
no test coverage detected