-
Notifications
You must be signed in to change notification settings - Fork 37.7k
util: Add ParseHex<std::byte>() helper #23595
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
The long-term idea is to move from |
I believe that the rationale behind |
Yes, in places where raw bytes are handled. Though, this is mostly a style question, so there is no rush or need to switch existing code. For example, #23438 updates serialize to use Spans, and updating to |
Concept ACK
Ok. I see. It would be incredibly difficult to port bitcoin to a system that doesn't have 8-bit memory units. |
@laanwj I don't think the point is generality; we very much assume that a byte is 8 bits all over the place. It's more a type safety thing: |
facdef4
to
fa606db
Compare
Thanks for the explanation. Yes a "memory area without interpretation" abstraction makes sense. I still have a hard time grasping when to use it though. We might want to add something to |
I think a good rule of thumb would be to use it only for "raw memory" or "serialized memory". That is, any kind of memory that needs to be passed through a deserializer/parser before being useful. For example: #23438 changes the serialize framework. |
fa606db
to
fac3349
Compare
Also, fix style in the corresponding function. The style change can be reviewed with "--word-diff-regex=."
fac3349
to
fa35be6
Compare
fa35be6
to
facd1fb
Compare
ACK facd1fb Does it make sense to mention this specifically in the Developer notes when to use std::byte? |
Yeah, I am happy to review a pull request that changes the dev notes, though it seems unrelated to this change here, since we already use |
Code review ACK facd1fb |
Post-merge ACK facd1fb |
facd1fb refactor: Use Span of std::byte in CExtKey::SetSeed (MarcoFalke) fae1006 util: Add ParseHex<std::byte>() helper (MarcoFalke) fabdf81 test: Add test for embedded null in hex string (MarcoFalke) Pull request description: This adds the hex->`std::byte` helper after the `std::byte`->hex helper was added in commit 9394964 ACKs for top commit: pk-b2: ACK bitcoin@facd1fb laanwj: Code review ACK facd1fb Tree-SHA512: e2329fbdea2e580bd1618caab31f5d0e59c245a028e1236662858e621929818870b76ab6834f7ac6a46d7874dfec63f498380ad99da6efe4218f720a60e859be
This adds the hex->
std::byte
helper after thestd::byte
->hex helper was added in commit 9394964