neoneo-go/pkg/core/interop/iterator/interop.go
Evgeniy Stratonikov 2130e17f0c core,vm: remove System.Enumerator.* interops
Map iterator now returns key-value pair, while array/byte-array
iterators work like old enumerators.
Follow neo-project/neo#2190.
2021-01-15 21:11:32 +03:00

23 lines
651 B
Go

package iterator
import (
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/vm"
)
// Create creates an iterator from array-like or map stack item.
func Create(ic *interop.Context) error {
return vm.IteratorCreate(ic.VM)
}
// Next advances the iterator, pushes true on success and false otherwise.
func Next(ic *interop.Context) error {
return vm.IteratorNext(ic.VM)
}
// Value returns current iterator value and depends on iterator type:
// For slices the result is just value.
// For maps the result is key-value pair packed in a struct.
func Value(ic *interop.Context) error {
return vm.IteratorValue(ic.VM)
}