Skip to content

Commit

Permalink
rpc: move UniValue in blockToJSON
Browse files Browse the repository at this point in the history
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: bitcoin#30094
Rebased-From: b77bad3
  • Loading branch information
willcl-ark authored and luke-jr committed May 13, 2024
1 parent 9f65006 commit 6ce4d5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,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;
}
Expand Down

0 comments on commit 6ce4d5a

Please sign in to comment.