Skip to content

Commit 0503cbe

Browse files
committed
Merge bitcoin/bitcoin#30094: rpc: move UniValue in blockToJSON
b77bad3 rpc: move UniValue in blockToJSON (willcl-ark) Pull request description: Fixes: #24542 Fixes: #30052 Without explicitly declaring the move, these `UniValues` get copied, causing increased memory usage. Fix this by explicitly moving the `UniValue` objects. Used by `rest_block` and `getblock` RPC. ACKs for top commit: maflcko: review ACK b77bad3 ismaelsadeeq: ACK b77bad3 TheCharlatan: ACK b77bad3 theuni: utACK b77bad3 hebasto: ACK b77bad3, I have reviewed the code and it looks OK. BrandonOdiwuor: ACK b77bad3 Tree-SHA512: 767608331040f9cfe5c3568ed0e3c338920633472a1a50d4bbb47d1dc69d2bb11466d611f050ac8ad1a894b47fe1ea4d968cf34cbd44d4bb8d479fc5c7475f6d
2 parents ff8c606 + b77bad3 commit 0503cbe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn
188188
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
189189
UniValue objTx(UniValue::VOBJ);
190190
TxToUniv(*tx, /*block_hash=*/uint256(), /*entry=*/objTx, /*include_hex=*/true, txundo, verbosity);
191-
txs.push_back(objTx);
191+
txs.push_back(std::move(objTx));
192192
}
193193
break;
194194
}
195195

196-
result.pushKV("tx", txs);
196+
result.pushKV("tx", std::move(txs));
197197

198198
return result;
199199
}

0 commit comments

Comments
 (0)