-
Notifications
You must be signed in to change notification settings - Fork 72
Fix iteration for prefixed storage #15
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
Conversation
| /// is known to be literal. | ||
| fn get_raw_or_lookup(&'db self, node: &[u8], partial_key: &[u8]) -> Result<Cow<'db, DBValue>, H::Out, C::Error> { | ||
| match (partial_key.is_empty(), C::try_decode_hash(node)) { | ||
| match (partial_key == nibbleslice::EMPTY_ENCODED, C::try_decode_hash(node)) { |
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.
a bit beyond the scope of the PR, but is this match assuming that only empty partial-keys could lead to nodes small enough to fit in the hash? A small partial key would easily break that if so
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.
Previously (before #12) there was a check for root node here. partial_key is the key up to the node. Only the root node has it empty.
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 see, maybe a comment about that?
| } | ||
|
|
||
| /// Encoded key for storage lookup | ||
| fn encoded_key(&self) -> ElasticArray36<u8> { |
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.
is this not also encoded somewhere else?
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 method of TrieDBIterator, which manages current key as a vector of nibbles. I considered switching to NibbleVec instead, that uses compact form and can be trivially converted to NibbleSlice. Unfortunately the conversion would only work for even number of nibbles, and it is not trivial to fix that.
Trie iteration was not implemented correctly in #12
Also switched tests to use prefixed storage.