MCPcopy Create free account
hub / github.com/chain/txvm / Resumer

Function Resumer

protocol/txvm/option.go:84–106  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

82// finalize step. This function can be called only once, since
83// calling it will affect the VM state.
84func 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.

Callers 1

materializeTxMethod · 0.92

Calls 5

recoverErrorMethod · 0.80
execMethod · 0.80
isEmptyMethod · 0.80
wraperrMethod · 0.80
runHooksMethod · 0.80

Tested by

no test coverage detected