Skip to content
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

Use more strict types in node-(de)serialization #372

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

richardpringle
Copy link
Contributor

@richardpringle richardpringle commented Nov 22, 2023

Use more strict types in node (de)serialization for storage. Strict type conversions eliminate some potential bugs in logic at compile-time.

This is the precursor to a more major refactor, moving storage (de)serialization implementations into the individual node-types.

root_hash: [u8; TRIE_HASH_LEN],
attrs: NodeAttributes,
is_encoded_longer_than_hash_len: Option<bool>,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 100% stack-based and can actually be (de)serialized in one shot. I didn't do that here though, that can be done later if necessary.

@@ -368,45 +369,55 @@ impl Storable for Node {
match meta_raw.as_deref()[TRIE_HASH_LEN + 1].try_into()? {
NodeTypeId::Branch => {
// TODO: add path
// TODO: figure out what this size is?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure it out later, I promise.

@richardpringle richardpringle force-pushed the use-an-enum-in-leaf-node-storable branch from 743cf84 to 267c95d Compare November 22, 2023 23:21
@richardpringle richardpringle force-pushed the refactor-node-serialization branch from 4232be2 to d1650bd Compare November 22, 2023 23:21
@richardpringle richardpringle force-pushed the use-an-enum-in-leaf-node-storable branch from 267c95d to ab20071 Compare November 22, 2023 23:23
@richardpringle richardpringle force-pushed the refactor-node-serialization branch from d1650bd to fd6e3b1 Compare November 22, 2023 23:25
Base automatically changed from use-an-enum-in-leaf-node-storable to main November 23, 2023 00:15
@richardpringle richardpringle marked this pull request as ready for review November 23, 2023 00:15
@richardpringle richardpringle force-pushed the refactor-node-serialization branch from fd6e3b1 to 49a0e8a Compare November 23, 2023 00:16
@richardpringle richardpringle merged commit b2b4da8 into main Nov 23, 2023
5 checks passed
@richardpringle richardpringle deleted the refactor-node-serialization branch November 23, 2023 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants