-
Notifications
You must be signed in to change notification settings - Fork 112
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
refactor: change RawContentKey to alloy_primites::Bytes #1431
refactor: change RawContentKey to alloy_primites::Bytes #1431
Conversation
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.
This is a good start, but I think that this PR should also make some changes in OverlayContentKey.
Here are the changes that we should do:
- remove
Into<Vec<u8>>
from supertraits set (we should useto_bytes
directly) - change
TryFrom<Vec<u8>, Error = ContentKeyError>
toTryFrom<RawContentKey, Error = ContentKeyError>
in supertraits set to_bytes
function should returnRawContentKey
I think some of these are trivial, but some might require refactoring (I don't know until I try). If refactoring is not huge, I would put it into this PR, otherwise, it would be fine to split it into multiple PRs.
Also, see https://www.conventionalcommits.org/en/v1.0.0/ for failing check. |
a5d5ff6
to
feaf9d5
Compare
feaf9d5
to
046a4e1
Compare
Implemented |
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.
Few comments, repeating in many places:
- we should use
RawContentKey::_
instead ofBytes::_
(example: Bytes::new())- this allows it easier to later replace
RawContentKey
with something else (instead of being alias) if we want to - it also makes code more explicit
- this allows it easier to later replace
- we should avoid unnecessary creating new objects, examples:
- use
RawContentKey::from_str
directly (instead of usinghex_decode
to getVec<u8>
and then convert that into RawContentKey) - remove
.clone()
when not needed).
- use
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 good! If you can address last 2 comments, and I will merge the PR.
} | ||
} | ||
|
||
impl From<&StateContentKey> for Vec<u8> { | ||
impl From<&StateContentKey> for RawContentKey { |
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.
This should be removed (similar to other ones)
You can ignore failing commitlint check, as I will squash and merge changes anyway. But for the future, problem is the commit message: "fix: CI fixes and resolved conflicts with master", because it starts with capital letter (maybe something that we should change in our configuration). |
585bbc8
to
88f0e87
Compare
Fixed the commit message and remove From impl for StateContentKey |
What was wrong?
Vec<u8>
was being used to represent Raw Content Key.See #1404 for details
How was it #fixed?
Replaced it with
alloy_primites::Bytes
To-Do