mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge bitcoin/bitcoin#27927: util: Allow std::byte and char Span serialization
fa38d86235Use only Span{} constructor for byte-like types where possible (MarcoFalke)fa257bc831util: Allow std::byte and char Span serialization (MarcoFalke) Pull request description: Seems odd to require developers to cast all byte-like spans passed to serialization to `unsigned char`-spans. Fix that by passing and accepting byte-like spans as-is. Finally, add tests and update the code to use just `Span` where possible. ACKs for top commit: sipa: utACKfa38d86235achow101: ACKfa38d86235ryanofsky: Code review ACKfa38d86235. This looks great. The second commit really removes a lot of boilerplate and shows why the first commit is useful. Tree-SHA512: 788592d9ff515c3ebe73d48f9ecbb8d239f5b985af86f09974e508cafb0ca6d73a959350295246b4dfb496149bc56330a0b5d659fc434ba6723dbaba0b7a49e5
This commit is contained in:
@@ -2933,13 +2933,13 @@ void CaptureMessageToFile(const CAddress& addr,
|
||||
AutoFile f{fsbridge::fopen(path, "ab")};
|
||||
|
||||
ser_writedata64(f, now.count());
|
||||
f.write(MakeByteSpan(msg_type));
|
||||
f << Span{msg_type};
|
||||
for (auto i = msg_type.length(); i < CMessageHeader::COMMAND_SIZE; ++i) {
|
||||
f << uint8_t{'\0'};
|
||||
}
|
||||
uint32_t size = data.size();
|
||||
ser_writedata32(f, size);
|
||||
f.write(AsBytes(data));
|
||||
f << data;
|
||||
}
|
||||
|
||||
std::function<void(const CAddress& addr,
|
||||
|
||||
Reference in New Issue
Block a user