This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
state_getSize RPC for storage maps #6847
Merged
Merged
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
261b95c
Fancy compact encode/decode impl for compact solution
kianenigma 973bd25
Merge branch 'master' of github.com:paritytech/substrate into kiz-cod…
kianenigma 0ff952c
Make it optional
kianenigma 8c7b07a
Remove extra file
kianenigma 41ad894
Update primitives/npos-elections/compact/src/lib.rs
kianenigma 03ce657
Final fixes.
kianenigma 82641f9
Merge branch 'kiz-codec-for-compact' of github.com:paritytech/substra…
kianenigma 1524c5b
Merge branch 'master' of github.com:paritytech/substrate into kiz-cod…
kianenigma 6fcb09e
getSize rpc should work for maps as well
kianenigma ba19fd3
Fix future types
kianenigma ba3eacd
Remove minimum_validator_count stale const
kianenigma b889970
Update client/rpc/src/state/mod.rs
kianenigma 66586a4
"Optimize" `storage_size`
bkchr 754098a
Remove unused import
bkchr 85532e1
Merge branch 'kiz-rpc-for-map-len' of github.com:paritytech/substrate…
kianenigma 11ff7ee
Update doc
kianenigma fcc7f0c
Merge branch 'master' of github.com:paritytech/substrate into kiz-cod…
kianenigma 41663f4
Merge branch 'kiz-rpc-for-map-len' of github.com:paritytech/substrate…
kianenigma e12e6c9
Merge branch 'master' of github.com:paritytech/substrate into kiz-rpc…
kianenigma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that query be done conditionally only if
value_lenresults intoNone?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that makes more sense and I initially started with that, but failed to get it to work. Ideally I want: only if the first one is
Ok(None), then try the second one.But I am not sure if this is even possible? I am but new to futures.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on the futures version we have here, but it seems it's 0.1 and I think it should be something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure I tried something like that and failed once, but let me try again and get back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so this was the first time I was working with futures and the main point of confusion was the versioning going on (which makes me appreciate more and more the standardised async/await). I wasn't aware that the
rpcus using and re-exporting0.1and the current crate is using0.3, and I was getting strange errors all over the place.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
storage_pairsfunction will return the results directly. You need to do this differently here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain more? I don't see the difference in what you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you call a function that returns a future, you can also directly return the result. This means the first time the future is polled the result is ready. However this also means that the operation is always executed, in this case the scanning of the storage. I propose that you put the scanning call into a closure and only call this closure if the first storage call returned a none. This means you will only scan the storage when the value does not exists vs query it always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exactly wanted to do as you explain: only query the second if the first one is
None. This is how I thought: callingself.storage_pairsand storing it inpairs_lenexecutes nothing, because it is not yet polled. I thought that also afterwards when I pass it toand_then, it is would be only polled in theNonearm, but apparently not.