github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/internal/basicchain/testdata/storage/storage_contract.go (about)

     1  /*
     2  Package storage contains contract that puts a set of values inside the storage on
     3  deploy. The contract has a single method returning iterator over these values.
     4  The contract is aimed to test iterator sessions RPC API.
     5  */
     6  package storage
     7  
     8  import (
     9  	"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
    10  	"github.com/nspcc-dev/neo-go/pkg/interop/storage"
    11  )
    12  
    13  // valuesCount is the amount of stored values.
    14  const valuesCount = 255
    15  
    16  // valuesPrefix is the prefix values are stored by.
    17  var valuesPrefix = []byte{0x01}
    18  
    19  func _deploy(data any, isUpdate bool) {
    20  	if !isUpdate {
    21  		ctx := storage.GetContext()
    22  		for i := 0; i < valuesCount; i++ {
    23  			key := append(valuesPrefix, byte(i))
    24  			storage.Put(ctx, key, i)
    25  		}
    26  	}
    27  
    28  }
    29  
    30  // IterateOverValues returns iterator over contract storage values stored during deploy.
    31  func IterateOverValues() iterator.Iterator {
    32  	ctx := storage.GetContext()
    33  	return storage.Find(ctx, valuesPrefix, storage.ValuesOnly)
    34  }