From 8e970b315b2b87e1d21b245613a2d110dfaea804 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 9 Dec 2020 06:28:01 +0300 Subject: [PATCH 1/2] rpc: Deprecate `masternode current` and `masternode winner` --- src/rpc/masternode.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 6422fd5849d6..d1d3c4a38afd 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -179,6 +179,10 @@ UniValue GetNextMasternodeForPayment(int heightShift) void masternode_winner_help() { + if (!IsDeprecatedRPCEnabled("masternode_winner")) { + throw std::runtime_error("DEPRECATED: set -deprecatedrpc=masternode_winner to enable it"); + } + throw std::runtime_error( "masternode winner\n" "Print info on next masternode winner to vote for\n" @@ -187,7 +191,7 @@ void masternode_winner_help() UniValue masternode_winner(const JSONRPCRequest& request) { - if (request.fHelp) + if (request.fHelp || !IsDeprecatedRPCEnabled("masternode_winner")) masternode_winner_help(); return GetNextMasternodeForPayment(10); @@ -195,6 +199,10 @@ UniValue masternode_winner(const JSONRPCRequest& request) void masternode_current_help() { + if (!IsDeprecatedRPCEnabled("masternode_current")) { + throw std::runtime_error("DEPRECATED: set -deprecatedrpc=masternode_current to enable it"); + } + throw std::runtime_error( "masternode current\n" "Print info on current masternode winner to be paid the next block (calculated locally)\n" @@ -203,7 +211,7 @@ void masternode_current_help() UniValue masternode_current(const JSONRPCRequest& request) { - if (request.fHelp) + if (request.fHelp || !IsDeprecatedRPCEnabled("masternode_current")) masternode_current_help(); return GetNextMasternodeForPayment(1); @@ -523,14 +531,14 @@ UniValue masternode_payments(const JSONRPCRequest& request) "1. \"command\" (string or set of strings, required) The command to execute\n" "\nAvailable commands:\n" " count - Get information about number of masternodes (DEPRECATED options: 'total', 'ps', 'enabled', 'qualify', 'all')\n" - " current - Print info on current masternode winner to be paid the next block (calculated locally)\n" + " current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n" #ifdef ENABLE_WALLET " outputs - Print masternode compatible outputs\n" #endif // ENABLE_WALLET " status - Print masternode status information\n" " list - Print list of all known masternodes (see masternodelist for more info)\n" " payments - Return information about masternode payments in a mined block\n" - " winner - Print info on next masternode winner to vote for\n" + " winner - DEPRECATED Print info on next masternode winner to vote for\n" " winners - Print list of masternode winners\n" ); } From b69b639b19769944ff177d7883f452b110504cca Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 24 Mar 2021 23:43:36 +0300 Subject: [PATCH 2/2] rpc: Drop deprecated `mode` param in `masternode count` --- src/rpc/masternode.cpp | 44 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index d1d3c4a38afd..b98fd55e08fe 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -107,52 +107,24 @@ UniValue masternode_connect(const JSONRPCRequest& request) void masternode_count_help() { throw std::runtime_error( - "masternode count (\"mode\")\n" - " Get information about number of masternodes. Mode\n" - " usage is depricated, call without mode params returns\n" - " all values in JSON format.\n" - "\nArguments:\n" - "1. \"mode\" (string, optional, DEPRICATED) Option to get number of masternodes in different states\n" - "\nAvailable modes:\n" - " total - total number of masternodes" - " cj - number of CoinJoin compatible masternodes" - " enabled - number of enabled masternodes" - " qualify - number of qualified masternodes" - " all - all above in one string" + "masternode count\n" + "Get information about number of masternodes.\n" ); } UniValue masternode_count(const JSONRPCRequest& request) { - if (request.fHelp || request.params.size() > 2) + if (request.fHelp || request.params.size() > 1) masternode_count_help(); auto mnList = deterministicMNManager->GetListAtChainTip(); int total = mnList.GetAllMNsCount(); int enabled = mnList.GetValidMNsCount(); - if (request.params.size() == 1) { - UniValue obj(UniValue::VOBJ); - - obj.pushKV("total", total); - obj.pushKV("enabled", enabled); - - return obj; - } - - std::string strMode = request.params[1].get_str(); - - if (strMode == "total") - return total; - - if (strMode == "enabled") - return enabled; - - if (strMode == "all") - return strprintf("Total: %d (Enabled: %d)", - total, enabled); - - throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown mode value"); + UniValue obj(UniValue::VOBJ); + obj.pushKV("total", total); + obj.pushKV("enabled", enabled); + return obj; } UniValue GetNextMasternodeForPayment(int heightShift) @@ -530,7 +502,7 @@ UniValue masternode_payments(const JSONRPCRequest& request) "\nArguments:\n" "1. \"command\" (string or set of strings, required) The command to execute\n" "\nAvailable commands:\n" - " count - Get information about number of masternodes (DEPRECATED options: 'total', 'ps', 'enabled', 'qualify', 'all')\n" + " count - Get information about number of masternodes\n" " current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n" #ifdef ENABLE_WALLET " outputs - Print masternode compatible outputs\n"