MCPcopy Create free account
hub / github.com/chain/Core / opPick

Function opPick

protocol/vm/stack.go:204–228  ·  view source on GitHub ↗
(vm *virtualMachine)

Source from the content-addressed store, hash-verified

202}
203
204func opPick(vm *virtualMachine) error {
205 err := vm.applyCost(2)
206 if err != nil {
207 return err
208 }
209 n, err := vm.popInt64(false)
210 if err != nil {
211 return err
212 }
213 if n < 0 {
214 return ErrBadValue
215 }
216 off, ok := checked.AddInt64(n, 1)
217 if !ok {
218 return ErrBadValue
219 }
220 if int64(len(vm.dataStack)) < off {
221 return ErrDataStackUnderflow
222 }
223 err = vm.push(vm.dataStack[int64(len(vm.dataStack))-(off)], false)
224 if err != nil {
225 return err
226 }
227 return nil
228}
229
230func opRoll(vm *virtualMachine) error {
231 err := vm.applyCost(2)

Callers

nothing calls this directly

Calls 4

applyCostMethod · 0.80
popInt64Method · 0.80
AddInt64Method · 0.80
pushMethod · 0.80

Tested by

no test coverage detected