nspcc-dev / neo-go

Go Node and SDK for the Neo blockchain
MIT License
123 stars 79 forks source link

Provide KV type in the interop/storage package #3607

Open roman-khimov opened 1 month ago

roman-khimov commented 1 month ago

Is your feature request related to a problem? Please describe.

I'm always frustrated when I see this:

    newNodes := storage.Find(ctx, newNodesPrefix, storage.None)
    for iterator.Next(newNodes) {
        newNode := iterator.Value(newNodes).(struct {
            key []byte
            val []byte
        })

Especially given the fact that this is not the first time I'm seeing it. We have similar code and types in other contracts dealing with updates or otherwise interacting with iterators returning KV pairs.

Describe the solution you'd like

Provide some type for KV pair.

Describe alternatives you've considered

Keep as is, explain and duplicate it again and again.

Additional context

https://github.com/nspcc-dev/neofs-contract/pull/438