2019-09-03 18:00:10 +03:00
|
|
|
package iteratorcontract
|
2018-08-31 10:23:57 +02:00
|
|
|
|
|
|
|
import (
|
2020-03-03 17:21:42 +03:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
2018-08-31 10:23:57 +02:00
|
|
|
)
|
|
|
|
|
2022-03-23 22:02:19 +03:00
|
|
|
// _deploy primes contract's storage with some data to be used later.
|
|
|
|
func _deploy(_ interface{}, _ bool) {
|
2022-03-23 22:05:40 +03:00
|
|
|
ctx := storage.GetContext() // RW context.
|
2022-03-23 22:02:19 +03:00
|
|
|
storage.Put(ctx, "foo1", "1")
|
|
|
|
storage.Put(ctx, "foo2", "2")
|
|
|
|
storage.Put(ctx, "foo3", "3")
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:05:40 +03:00
|
|
|
// NotifyKeysAndValues sends notification with `foo` storage keys and values.
|
2020-08-10 13:42:02 +03:00
|
|
|
func NotifyKeysAndValues() bool {
|
2022-03-23 22:05:40 +03:00
|
|
|
iter := storage.Find(storage.GetReadOnlyContext(), []byte("foo"), storage.None)
|
2021-01-12 12:30:21 +03:00
|
|
|
for iterator.Next(iter) {
|
2022-03-23 22:05:40 +03:00
|
|
|
runtime.Notify("Key-Value", iterator.Value(iter))
|
2021-01-12 12:30:21 +03:00
|
|
|
}
|
2018-08-31 10:23:57 +02:00
|
|
|
return true
|
|
|
|
}
|
2022-03-23 22:04:17 +03:00
|
|
|
|
|
|
|
// NotifyValues sends notification with `foo` storage values.
|
|
|
|
func NotifyValues() bool {
|
2022-03-23 22:05:40 +03:00
|
|
|
iter := storage.Find(storage.GetReadOnlyContext(), []byte("foo"), storage.ValuesOnly)
|
2022-03-23 22:04:17 +03:00
|
|
|
for iterator.Next(iter) {
|
|
|
|
runtime.Notify("Value", iterator.Value(iter))
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|