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

Function findAndRoll

protocol/txbuilder/template.go:661–673  ·  view source on GitHub ↗
(b *txvmutil.Builder, stack []stackItem, f func(int, stackItem) bool)

Source from the content-addressed store, hash-verified

659}
660
661func findAndRoll(b *txvmutil.Builder, stack []stackItem, f func(int, stackItem) bool) []stackItem {
662 for i := len(stack) - 1; i >= 0; i-- {
663 if f(i, stack[i]) {
664 if i == len(stack)-1 {
665 return stack
666 }
667 b.PushdataInt64(int64(len(stack) - i - 1))
668 b.Op(op.Roll)
669 return append(stack[:i], append(stack[i+1:], stack[i])...)
670 }
671 }
672 return nil
673}
674
675func bury(b *txvmutil.Builder, stack []stackItem, n int) []stackItem {
676 b.PushdataInt64(int64(n)) // <n>

Callers 3

zerovalToTopSplitFunction · 0.85
zerovalToTopFunction · 0.85
valueToTopFunction · 0.85

Calls 2

OpMethod · 0.80
PushdataInt64Method · 0.45

Tested by

no test coverage detected