-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement iter_keys
function for all types of storage maps
#9238
Conversation
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.
Looks good. I'm not convinced that drain_keys
and friends are really worth it; it seems like they're justified only if decoding the values takes non-trivial time. If you do choose to keep them, it would be good to test them, not just the iter_keys
variants.
Still, the code overall looks good.
prefix: Vec<u8>, | ||
previous_key: Vec<u8>, | ||
/// If true then value are removed while iterating | ||
drain: bool, |
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.
This is a normal way of doing 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.
We do similar for PrefixIterator, that would allow use to create drain_keys
easily if we want.
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 actually spend a few minutes trying to see if we can merge this with PrefixIterator
, the impls are pretty similar, only the decoding closure is different.
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.
@kianenigma seems hard to have the output be only keys or also keys and values. (i.e. making an API that makes sense and works in both scenarios?)
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.
LGTM
bot merge |
Waiting for commit status. |
Fixes #9118.