diff options
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r-- | src/rpc/mining.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 454c262803..63daa3da3a 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -3,9 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#if defined(HAVE_CONFIG_H) -#include <config/bitcoin-config.h> -#endif +#include <config/bitcoin-config.h> // IWYU pragma: keep #include <chain.h> #include <chainparams.h> @@ -33,13 +31,13 @@ #include <script/signingprovider.h> #include <txmempool.h> #include <univalue.h> +#include <util/signalinterrupt.h> #include <util/strencodings.h> #include <util/string.h> #include <util/time.h> #include <util/translation.h> #include <validation.h> #include <validationinterface.h> -#include <warnings.h> #include <memory> #include <stdint.h> @@ -426,7 +424,14 @@ static RPCHelpMan getmininginfo() {RPCResult::Type::NUM, "networkhashps", "The network hashes per second"}, {RPCResult::Type::NUM, "pooledtx", "The size of the mempool"}, {RPCResult::Type::STR, "chain", "current network name (main, test, signet, regtest)"}, - {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"}, + (IsDeprecatedRPCEnabled("warnings") ? + RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} : + RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)", + { + {RPCResult::Type::STR, "", "warning"}, + } + } + ), }}, RPCExamples{ HelpExampleCli("getmininginfo", "") @@ -448,7 +453,7 @@ static RPCHelpMan getmininginfo() obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request)); obj.pushKV("pooledtx", (uint64_t)mempool.size()); obj.pushKV("chain", chainman.GetParams().GetChainTypeString()); - obj.pushKV("warnings", GetWarnings(false).original); + obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings"))); return obj; }, }; @@ -480,7 +485,7 @@ static RPCHelpMan prioritisetransaction() LOCK(cs_main); uint256 hash(ParseHashV(request.params[0], "txid")); - const auto dummy{self.MaybeArg<double>(1)}; + const auto dummy{self.MaybeArg<double>("dummy")}; CAmount nAmount = request.params[2].getInt<int64_t>(); if (dummy && *dummy != 0) { @@ -524,7 +529,7 @@ static RPCHelpMan getprioritisedtransactions() if (delta_info.in_mempool) { result_inner.pushKV("modified_fee", *delta_info.modified_fee); } - rpc_result.pushKV(delta_info.txid.GetHex(), result_inner); + rpc_result.pushKV(delta_info.txid.GetHex(), std::move(result_inner)); } return rpc_result; }, @@ -849,7 +854,7 @@ static RPCHelpMan getblocktemplate() if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); } - entry.pushKV("depends", deps); + entry.pushKV("depends", std::move(deps)); int index_in_template = i - 1; entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]); @@ -861,7 +866,7 @@ static RPCHelpMan getblocktemplate() entry.pushKV("sigops", nTxSigOps); entry.pushKV("weight", GetTransactionWeight(tx)); - transactions.push_back(entry); + transactions.push_back(std::move(entry)); } UniValue aux(UniValue::VOBJ); @@ -874,7 +879,7 @@ static RPCHelpMan getblocktemplate() aMutable.push_back("prevblock"); UniValue result(UniValue::VOBJ); - result.pushKV("capabilities", aCaps); + result.pushKV("capabilities", std::move(aCaps)); UniValue aRules(UniValue::VARR); aRules.push_back("csv"); @@ -926,18 +931,18 @@ static RPCHelpMan getblocktemplate() } } result.pushKV("version", pblock->nVersion); - result.pushKV("rules", aRules); - result.pushKV("vbavailable", vbavailable); + result.pushKV("rules", std::move(aRules)); + result.pushKV("vbavailable", std::move(vbavailable)); result.pushKV("vbrequired", int(0)); result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); - result.pushKV("transactions", transactions); - result.pushKV("coinbaseaux", aux); + result.pushKV("transactions", std::move(transactions)); + result.pushKV("coinbaseaux", std::move(aux)); result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue); result.pushKV("longpollid", active_chain.Tip()->GetBlockHash().GetHex() + ToString(nTransactionsUpdatedLast)); result.pushKV("target", hashTarget.GetHex()); result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1); - result.pushKV("mutable", aMutable); + result.pushKV("mutable", std::move(aMutable)); result.pushKV("noncerange", "00000000ffffffff"); int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST; int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE; |