-
Notifications
You must be signed in to change notification settings - Fork 16
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
turbohash #171
turbohash #171
Conversation
assert_eq!(r.unwrap()[0], true); | ||
assert_eq!(node.items(), 0); | ||
assert_eq!(node.hash(), empty_hash()); | ||
assert_eq!(node.hash(), Vec::<u8>::new()); |
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.
note a subtle change here
assert_eq!(r.unwrap()[0], true); | ||
assert_eq!(node.items(), 0); | ||
assert_eq!(node.hash(), empty_hash()); | ||
assert_eq!(node.hash(), Vec::<u8>::new()); |
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.
note a subtle change here
@@ -122,15 +124,25 @@ impl TrieNode { | |||
for char in db_trie_node.child_chars { | |||
children.insert( | |||
char as u8, | |||
TrieNodeType::Serialized(SerializedTrieNode::new(None)), | |||
TrieNodeType::Serialized(SerializedTrieNode::new()), |
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.
If the struct is empty, do we actually need the struct?
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.
left a TODO comment
22bb674
to
d0d04ba
Compare
d0d04ba
to
866b31e
Compare
This change stores the hash of a trie node in the node's parent (in a hashmap).
This yields an important performance improvement when recomputing the hash of a changed node. Previously, when recomputing the hash, as we are working our way up the trie, we had to load siblings of a changed node out of the db. In this version, the sibling hashes are already loaded, which dramatically reduces the number of db reads.