-
Notifications
You must be signed in to change notification settings - Fork 5
Description
In the legacy RPC methods, a user could call state_getKeysPaged with some prefix, and provide a starting key (and number of keys to fetch). They are able to then paginate over the child keys/values by tracking the last key that they have seen and using that to request the next batch of keys (and obtain values for them). This is resistant to network connection interruptions and such; they can always pick up from the last key they are interested in.
Using the new chainHead_storage API, a couple of things make iterating over descendent keys/values harder:
- There is no way to just ask for descendent keys (I guess I'd ask for
descendentHashesand then just ignore them and look at the keys, but this is less than ideal). - There is no way to pick up from where I left off in case the
chainHeadsubscription I'm relying on stops for any reason (eg network interruption or pinned blocks getting too old).
Proposals
Being able to provide a startKey to the chainHead_storage items of type descendantsValues and descendantsHashes would probably go most of the way here (I'm not super sure if it's useful to be able to fetch keys without fetching values in the usual case of paginating over some descendent results).
I also wondered about supporting a new type like descendantsKeys in storage items. This would return only the keys, and no other values (so that you can eg download all of the keys and then ask for values later as a user paginates through some interface or whatever). If the startKey idea is acceptable then this would also allow a startKey to align with other descendants* types, and allow for reliable pagination/resuming of fetching keys as well as values or hashes.
What do you guys reckon?