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

Add multi trie management #21

Merged
merged 26 commits into from
Apr 1, 2024

Conversation

AurelienFT
Copy link
Collaborator

No description provided.

@AurelienFT AurelienFT marked this pull request as ready for review March 25, 2024 09:50
src/lib.rs Outdated Show resolved Hide resolved
src/trie/merkle_tree.rs Show resolved Hide resolved
Comment on lines 261 to 268
/// Note to developers : Must be used to build a key for the database.
// Allow because needed for no-std
#[allow(clippy::ptr_arg)]
pub fn build_db_key(identifier: &Vec<u8>, key: &[u8]) -> Vec<u8> {
let mut db_key = identifier.clone();
db_key.extend_from_slice(key);
db_key
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the key created by the concatenation of the storagekey and the identifier be it's own type?
So that it is enforced at the compiler level that the concatenation has been done and we are not just returning the storage key, which is also a Vec<u8>.
Otherwise future developer can easily write code that contains this error

Ideally we could create wrapper type for both the identifier and the trie key, and combine them to create a DatabaseKey

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed this function and used a constructor for the type TrieKey which is way more clearer now.

@@ -104,25 +104,25 @@ impl Path {
}
}

impl From<Path> for TrieKey {
impl From<Path> for Vec<u8> {
Copy link
Contributor

Choose a reason for hiding this comment

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

yup, rather than removing the TrieKey and having everything be a Vec<u8> I would prefer add more distinct types and be explicit about which one should be used at each step and how they combine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just added a comment because I don't want this conversion to be "key specific" but used for different use cases where you need Path as Vec<u8>

@tdelabro tdelabro merged commit 8ecf0c6 into madara-alliance:oss Apr 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants