-
Notifications
You must be signed in to change notification settings - Fork 218
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 array-bytes
for array/bytes/hex operations
#695
base: master
Are you sure you want to change the base?
Conversation
fixed-hash/src/hash.rs
Outdated
} | ||
Ok(result) | ||
fn from_str(input: &str) -> $crate::core_::result::Result<$name, $crate::array_bytes::Error> { | ||
$crate::array_bytes::hex_n_into::<Self, { Self::len_bytes() }>(input) |
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.
As you can see, it has some really friendly APIs.
And it will handle the "0x"
prefix and errors.
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.
Looks ok to me, but it is incomplete (good to merge once it passes CI)
Fixed. And it looks like there are some new errors in your CI script. |
And I made some algorithm optimization these days. Check the benchmark results here. Not only it has blockchain-developer-friendly API. I think it's also |
Hi! Any plan for this? |
Can you resolve the merge conflict? |
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've taken a look before and remained unconvinced.
One of the benefits advertized:
And it's completely no-std.
We could also use rustc-hex
without it's std
feature and call it completely no-std this way.
By switfly looking at https://github.com/hack-ink/array-bytes/blob/main/src/lib.rs I see a few problems:
- It's using unidiomatic function naming: https://rust-lang.github.io/api-guidelines/naming.html
- Unwraps and safe
unchecked
methods. - It's not audited.
So what's the benefit, really?
Some(&self.inner) | ||
// Some(&self.inner) | ||
// TODO: <https://github.com/rust-lang/project-error-handling/issues/3> | ||
None |
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.
^^^
For me, I want to bring these to other blockchain developers. It's really an honor and a good example to be a part of the parity-common (one of the most frequently used blockchain library). Would you consider this? |
Reasons: paritytech/substrate#12111
Substrate PR: paritytech/substrate#12190