Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StorageIterator #19

Closed
ixje opened this issue Mar 16, 2018 · 5 comments
Closed

Add StorageIterator #19

ixje opened this issue Mar 16, 2018 · 5 comments

Comments

@ixje
Copy link

ixje commented Mar 16, 2018

It's added to neo-project but not yet in the smart contract framework so can't use it.
neo-project/neo@a234978f2

@ixje
Copy link
Author

ixje commented Mar 17, 2018

Note that I've been able to compile a contract with Storage.Find using this fork however there seem to be 2 issues

  1. The iterator cannot be used in a foreach loop due to a missing public definition of GetEnumerator
    img

  2. prefix searching doesn't seem to work, returns an empty 'list' given the code below

    public class Contract1 : SmartContract
    {
        public static void Main()
        {
            Storage.Put(Storage.CurrentContext, "my_prefixA", "1");
            Storage.Put(Storage.CurrentContext, "my_prefixB", "2");
            Storage.Put(Storage.CurrentContext, "something", "3");
            StorageIterator si = Storage.Find(Storage.CurrentContext, "my_prefix");

            Runtime.Notify("Starting");
            while (si.Next())
            {
                Runtime.Notify(si.Key);
            }
            Runtime.Notify("Done");
        }
    }

@RavenXce
Copy link
Contributor

Yes, I believe the implementation of StorageIterator is bugged. I've been meaning to file a separate issue. I think the key prefix should have a length between it and the scriptHash.

@ixje
Copy link
Author

ixje commented Mar 22, 2018

Thanks for the quick handling of the bug in neo-project/neo#200 🥇! Looking forward to see this issue resolved so I can finalise the neo-python implementation with some cross platform tests

@ixje
Copy link
Author

ixje commented Mar 23, 2018

hi @erikzhang, you closed this issue but it's actually not resolved yet. Only the neo core Storage.Find implementation is fixed, but this official devpack does not support Storage.Find yet so others cannot use it unless they know about and use the fork from @RavenXce / Switcheo master...ConjurTech:add-apis

@RavenXce
Copy link
Contributor

I will make a PR since it works correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants