mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-16 21:20:43 +02:00
cli: reduce DefaultRequestHandler memory allocations
This commit is contained in:
parent
8783bcc099
commit
f20b359bb9
@ -516,8 +516,8 @@ static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
|
|||||||
*/
|
*/
|
||||||
static void GetWalletBalances(UniValue& result)
|
static void GetWalletBalances(UniValue& result)
|
||||||
{
|
{
|
||||||
std::unique_ptr<BaseRequestHandler> rh{MakeUnique<DefaultRequestHandler>()};
|
DefaultRequestHandler rh;
|
||||||
const UniValue listwallets = ConnectAndCallRPC(rh.get(), "listwallets", /* args=*/{});
|
const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{});
|
||||||
if (!find_value(listwallets, "error").isNull()) return;
|
if (!find_value(listwallets, "error").isNull()) return;
|
||||||
const UniValue& wallets = find_value(listwallets, "result");
|
const UniValue& wallets = find_value(listwallets, "result");
|
||||||
if (wallets.size() <= 1) return;
|
if (wallets.size() <= 1) return;
|
||||||
@ -525,7 +525,7 @@ static void GetWalletBalances(UniValue& result)
|
|||||||
UniValue balances(UniValue::VOBJ);
|
UniValue balances(UniValue::VOBJ);
|
||||||
for (const UniValue& wallet : wallets.getValues()) {
|
for (const UniValue& wallet : wallets.getValues()) {
|
||||||
const std::string wallet_name = wallet.get_str();
|
const std::string wallet_name = wallet.get_str();
|
||||||
const UniValue getbalances = ConnectAndCallRPC(rh.get(), "getbalances", /* args=*/{}, wallet_name);
|
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
|
||||||
const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
|
const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
|
||||||
balances.pushKV(wallet_name, balance);
|
balances.pushKV(wallet_name, balance);
|
||||||
}
|
}
|
||||||
@ -540,8 +540,8 @@ static UniValue GetNewAddress()
|
|||||||
{
|
{
|
||||||
Optional<std::string> wallet_name{};
|
Optional<std::string> wallet_name{};
|
||||||
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
|
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
|
||||||
std::unique_ptr<BaseRequestHandler> rh{MakeUnique<DefaultRequestHandler>()};
|
DefaultRequestHandler rh;
|
||||||
return ConnectAndCallRPC(rh.get(), "getnewaddress", /* args=*/{}, wallet_name);
|
return ConnectAndCallRPC(&rh, "getnewaddress", /* args=*/{}, wallet_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user