mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-07 11:39:01 +02:00
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
This commit is contained in:
parent
7f45e00174
commit
6685affe92
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user