-
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
Add multi trie management #21
Add multi trie management #21
Conversation
src/trie/merkle_tree.rs
Outdated
/// 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 | ||
} |
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.
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
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 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> { |
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.
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
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 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>
No description provided.