Skip to content

Commit f20b359

Browse files
committed
cli: reduce DefaultRequestHandler memory allocations
1 parent 8783bcc commit f20b359

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)