util: Add ParseHex<std::byte>() helper#23595
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::bytehelper after thestd::byte->hex helper was added in commit 9394964