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

Function rot

protocol/vm/stack.go:265–279  ·  view source on GitHub ↗
(vm *virtualMachine, n int64)

Source from the content-addressed store, hash-verified

263}
264
265func rot(vm *virtualMachine, n int64) error {
266 if n < 1 {
267 return ErrBadValue
268 }
269 if int64(len(vm.dataStack)) < n {
270 return ErrDataStackUnderflow
271 }
272 index := int64(len(vm.dataStack)) - n
273 newStack := make([][]byte, 0, len(vm.dataStack))
274 newStack = append(newStack, vm.dataStack[:index]...)
275 newStack = append(newStack, vm.dataStack[index+1:]...)
276 newStack = append(newStack, vm.dataStack[index])
277 vm.dataStack = newStack
278 return nil
279}
280
281func opSwap(vm *virtualMachine) error {
282 err := vm.applyCost(1)

Callers 2

opRollFunction · 0.85
opRotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected