diff options
author | willcl-ark <will@256k1.dev> | 2024-05-10 20:01:05 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2024-05-14 08:14:33 +0800 |
commit | 0ba11cf90869fb437f6dce0c9430be4f899c0ea1 (patch) | |
tree | 7a5df0debe4396efa2b0c9d335a2c1fa5303db53 | |
parent | dedf319b08d5b76dc1752d8bc4e14d38dc54e100 (diff) |
rpc: move UniValue in blockToJSON
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.
Github-Pull: #30094
Rebased-From: b77bad309e92f176f340598eec056eb7bff86f5f
-rw-r--r-- | src/rpc/blockchain.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 50908e9f96..0211a8a106 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -188,12 +188,12 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr; UniValue objTx(UniValue::VOBJ); TxToUniv(*tx, /*block_hash=*/uint256(), /*entry=*/objTx, /*include_hex=*/true, txundo, verbosity); - txs.push_back(objTx); + txs.push_back(std::move(objTx)); } break; } - result.pushKV("tx", txs); + result.pushKV("tx", std::move(txs)); return result; } |