diff --git a/pkg/core/storage_find.go b/pkg/core/storage_find.go index 14231896d..740a9edd5 100644 --- a/pkg/core/storage_find.go +++ b/pkg/core/storage_find.go @@ -11,6 +11,8 @@ type storageWrapper struct { finished bool } +var _ vm.Iterator = (*storageWrapper)(nil) + // newStorageIterator returns new storage iterator from the `next()` callback. func newStorageIterator(next dao.StorageIteratorFunc) *storageWrapper { return &storageWrapper{ @@ -18,7 +20,7 @@ func newStorageIterator(next dao.StorageIteratorFunc) *storageWrapper { } } -// Next implements iterator interface. +// Next implements vm.Iterator interface. func (s *storageWrapper) Next() bool { if s.finished { return false @@ -33,12 +35,12 @@ func (s *storageWrapper) Next() bool { return true } -// Value implements iterator interface. +// Value implements vm.Iterator interface. func (s *storageWrapper) Value() vm.StackItem { return s.value } -// Key implements iterator interface. +// Key implements vm.Iterator interface. func (s *storageWrapper) Key() vm.StackItem { return s.key } diff --git a/pkg/vm/interop.go b/pkg/vm/interop.go index d1ec282ba..b8a2cbf21 100644 --- a/pkg/vm/interop.go +++ b/pkg/vm/interop.go @@ -205,9 +205,9 @@ func NewMapIterator(m *MapItem) *InteropItem { // IteratorConcat handles syscall Neo.Iterator.Concat. func IteratorConcat(v *VM) error { iop1 := v.Estack().Pop().Interop() - iter1 := iop1.value.(iterator) + iter1 := iop1.value.(Iterator) iop2 := v.Estack().Pop().Interop() - iter2 := iop2.value.(iterator) + iter2 := iop2.value.(Iterator) v.Estack().Push(&Element{value: NewInteropItem( &concatIter{ @@ -222,7 +222,7 @@ func IteratorConcat(v *VM) error { // IteratorKey handles syscall Neo.Iterator.Key. func IteratorKey(v *VM) error { iop := v.estack.Pop().Interop() - iter := iop.value.(iterator) + iter := iop.value.(Iterator) v.Estack().Push(&Element{value: iter.Key()}) return nil @@ -231,7 +231,7 @@ func IteratorKey(v *VM) error { // IteratorKeys handles syscall Neo.Iterator.Keys. func IteratorKeys(v *VM) error { iop := v.estack.Pop().Interop() - iter := iop.value.(iterator) + iter := iop.value.(Iterator) v.Estack().Push(&Element{value: NewInteropItem( &keysWrapper{iter}, )}) @@ -242,7 +242,7 @@ func IteratorKeys(v *VM) error { // IteratorValues handles syscall Neo.Iterator.Values. func IteratorValues(v *VM) error { iop := v.estack.Pop().Interop() - iter := iop.value.(iterator) + iter := iop.value.(Iterator) v.Estack().Push(&Element{value: NewInteropItem( &valuesWrapper{iter}, )}) diff --git a/pkg/vm/interop_iterators.go b/pkg/vm/interop_iterators.go index 8ecf69b83..eb415de35 100644 --- a/pkg/vm/interop_iterators.go +++ b/pkg/vm/interop_iterators.go @@ -18,7 +18,8 @@ type ( ) type ( - iterator interface { + // Iterator defined public interface for VM's iterator type. + Iterator interface { enumerator Key() StackItem } @@ -29,16 +30,16 @@ type ( } concatIter struct { - current iterator - second iterator + current Iterator + second Iterator } keysWrapper struct { - iter iterator + iter Iterator } valuesWrapper struct { - iter iterator + iter Iterator } )