Skip to content

Commit 5802ea6

Browse files
author
MarcoFalke
committed
Merge #19453: refactor: reduce DefaultRequestHandler memory allocations
f20b359 cli: reduce DefaultRequestHandler memory allocations (Jon Atack) Pull request description: per bitcoin/bitcoin#16439 (comment). Simpler code, fewer allocations. No change of behavior. The code has good test coverage in `interface_bitcoin_cli.py`. ACKs for top commit: MarcoFalke: review ACK f20b359 fjahr: Code review ACK f20b359 Tree-SHA512: 745eab44dfdcc485ca2bbc1db8b8d364cbd3cf94982e46e033745ce05ab617c15320ee55da7fb930d365f4d26b172049d5f5efcf0b6d3af5b0a28185bdb93ea8
2 parents c0b0b02 + f20b359 commit 5802ea6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/bitcoin-cli.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,16 @@ static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
516516
*/
517517
static void GetWalletBalances(UniValue& result)
518518
{
519-
std::unique_ptr<BaseRequestHandler> rh{MakeUnique<DefaultRequestHandler>()};
520-
const UniValue listwallets = ConnectAndCallRPC(rh.get(), "listwallets", /* args=*/{});
519+
DefaultRequestHandler rh;
520+
const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{});
521521
if (!find_value(listwallets, "error").isNull()) return;
522522
const UniValue& wallets = find_value(listwallets, "result");
523523
if (wallets.size() <= 1) return;
524524

525525
UniValue balances(UniValue::VOBJ);
526526
for (const UniValue& wallet : wallets.getValues()) {
527527
const std::string wallet_name = wallet.get_str();
528-
const UniValue getbalances = ConnectAndCallRPC(rh.get(), "getbalances", /* args=*/{}, wallet_name);
528+
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
529529
const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
530530
balances.pushKV(wallet_name, balance);
531531
}
@@ -540,8 +540,8 @@ static UniValue GetNewAddress()
540540
{
541541
Optional<std::string> wallet_name{};
542542
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
543-
std::unique_ptr<BaseRequestHandler> rh{MakeUnique<DefaultRequestHandler>()};
544-
return ConnectAndCallRPC(rh.get(), "getnewaddress", /* args=*/{}, wallet_name);
543+
DefaultRequestHandler rh;
544+
return ConnectAndCallRPC(&rh, "getnewaddress", /* args=*/{}, wallet_name);
545545
}
546546

547547
/**

0 commit comments

Comments
 (0)