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