mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-12 08:37:58 +02:00
Merge bitcoin/bitcoin#34483: refactor: Use SpanReader over DataStream
fa0677d131refactor: Use SpanReader over DataStream (MarcoFalke)fad3eb3956refactor: Use SpanReader over DataStream (MarcoFalke)fa06e26764refactor: [qt] Use SpanReader to avoid two vector copies (MarcoFalke)fabd4d2e2erefactor: Avoid UB in SpanReader::ignore (MarcoFalke)fa20bc2ec2refactor: Use empty() over eof() in the streams interface (MarcoFalke)fa879db735test: Read debug log for self-checking comment (MarcoFalke) Pull request description: This changes all places, where possible, to use SpanReader over DataStream. This makes the code easier to read and reason about, because `SpanReader` can never write data. Also, the code should be minimally faster, because it avoids a full redundant copy of the whole vector of bytes. ACKs for top commit: stickies-v: re-ACKfa0677d131achow101: ACKfa0677d131janb84: re ACKfa0677d131sipa: crACKfa0677d131Tree-SHA512: 1d9f43fc6e71d481cf7b8f8457f479745ee331734649e9e2c2ab00ce5d317112796c77afc328612ed004e65ac5c16fc92279d760cfb012cfddce9098c4af810f
This commit is contained in:
@@ -503,7 +503,7 @@ btck_Transaction* btck_transaction_create(const void* raw_transaction, size_t ra
|
||||
return nullptr;
|
||||
}
|
||||
try {
|
||||
DataStream stream{std::span{reinterpret_cast<const std::byte*>(raw_transaction), raw_transaction_len}};
|
||||
SpanReader stream{std::span{reinterpret_cast<const std::byte*>(raw_transaction), raw_transaction_len}};
|
||||
return btck_Transaction::create(std::make_shared<const CTransaction>(deserialize, TX_WITH_WITNESS, stream));
|
||||
} catch (...) {
|
||||
return nullptr;
|
||||
@@ -1092,7 +1092,7 @@ btck_Block* btck_block_create(const void* raw_block, size_t raw_block_length)
|
||||
}
|
||||
auto block{std::make_shared<CBlock>()};
|
||||
|
||||
DataStream stream{std::span{reinterpret_cast<const std::byte*>(raw_block), raw_block_length}};
|
||||
SpanReader stream{std::span{reinterpret_cast<const std::byte*>(raw_block), raw_block_length}};
|
||||
|
||||
try {
|
||||
stream >> TX_WITH_WITNESS(*block);
|
||||
@@ -1343,7 +1343,7 @@ btck_BlockHeader* btck_block_header_create(const void* raw_block_header, size_t
|
||||
return nullptr;
|
||||
}
|
||||
auto header{std::make_unique<CBlockHeader>()};
|
||||
DataStream stream{std::span{reinterpret_cast<const std::byte*>(raw_block_header), raw_block_header_len}};
|
||||
SpanReader stream{std::span{reinterpret_cast<const std::byte*>(raw_block_header), raw_block_header_len}};
|
||||
|
||||
try {
|
||||
stream >> *header;
|
||||
|
||||
Reference in New Issue
Block a user