diff options
author | willcl-ark <will@256k1.dev> | 2024-05-10 20:01:05 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2024-05-23 17:05:57 +0100 |
commit | 6685affe92ce61a586d257b3ccdf0d97f8b9ef85 (patch) | |
tree | d76ddccb206a9f231d06f2a174a2bd602e29d100 | |
parent | 7f45e0017417d1a100c60ff02cc72eb788b6f9c6 (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 7b84747a3f..1ed1ed50c2 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -190,12 +190,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, RPCSerializationFlags(), 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; } |