mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-08 06:37:50 +02:00
refactor: Use SpanReader over DataStream
This refactor does not change behavior. However, it avoids a vector copy, which can lead to a minimal speed-up of 1%-5%, depending on the call-site. This is mostly relevant for the fuzz tests and utils that read large blobs of data (like a full block).
This commit is contained in:
@@ -451,8 +451,7 @@ static bool rest_block(const std::any& context,
|
||||
case RESTResponseFormat::JSON: {
|
||||
if (tx_verbosity) {
|
||||
CBlock block{};
|
||||
DataStream block_stream{*block_data};
|
||||
block_stream >> TX_WITH_WITNESS(block);
|
||||
SpanReader{*block_data} >> TX_WITH_WITNESS(block);
|
||||
UniValue objBlock = blockToJSON(chainman.m_blockman, block, *tip, *pblockindex, *tx_verbosity, chainman.GetConsensus().powLimit);
|
||||
std::string strJSON = objBlock.write() + "\n";
|
||||
req->WriteHeader("Content-Type", "application/json");
|
||||
|
||||
Reference in New Issue
Block a user