-
Notifications
You must be signed in to change notification settings - Fork 1k
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
StorageIterator does not work #199
Comments
For what it's worth, in |
Since the keys in the db change does that mean that nodes need to re-build storage on upgrade? The other solution here is to change how Put/Get/Delete works as well, but I thought that would be more complicated. |
Yes for Put(ctx, 'my_prefixA', 1)
Put(ctx, 'my_prefixB', 2) would generate the following DB keys:
It was deterministic befor and would save space, but as can be seen that would never reasonable be prefix searchable. |
I guess thats a possible solution here too. I've tested and can confirm the issue is due to the key prefix as mentioned in OP. Manually prefixing an additional key length in addition to the desired prefix allows keys with that length and prefix to be returned. |
…o-project#199) * correction for parameter types in deploy example * correction for parameter types in Woolong example code comments
Please see neo-project/neo-devpack-dotnet#19 (comment) for example reproduction.
The issue is that when doing the prefix building in
Storage.Find
, the contract script hash and storage prefix are simply concatenated.neo/neo/SmartContract/StateReader.cs
Line 951 in f49f266
However, for Storage.Put/Get, I believe that serialization uses WriteVarBytes for the key portion:
neo/neo/Core/StorageKey.cs
Line 46 in 07dd1f5
Which prefixes the length of the key:
neo/neo/IO/Helper.cs
Line 190 in 115a402
I think we can safely construct and then serialize a StorageKey instead to ensure they match?
Edit: Actually, the length prefix messes up the whole implementation - one way to make it work is by specifying key length, so the keys iterated on are constrained to a single length and must be known.
The text was updated successfully, but these errors were encountered: