|
| 1 | +// Copyright (c) 2018-2021 The Dash Core developers |
| 2 | +// Copyright (c) 2022 The PIVX Core developers |
| 3 | +// Distributed under the MIT software license, see the accompanying |
| 4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | + |
| 6 | +#include "activemasternode.h" |
| 7 | +#include "chainparams.h" |
| 8 | +#include "llmq/quorums_blockprocessor.h" |
| 9 | +#include "llmq/quorums_commitment.h" |
| 10 | +#include "llmq/quorums_debug.h" |
| 11 | +#include "llmq/quorums_utils.h" |
| 12 | +#include "net.h" |
| 13 | +#include "rpc/server.h" |
| 14 | +#include "validation.h" |
| 15 | + |
| 16 | + |
| 17 | +UniValue quorumdkgstatus(const JSONRPCRequest& request) |
| 18 | +{ |
| 19 | + if (request.fHelp || request.params.size() > 1) { |
| 20 | + throw std::runtime_error( |
| 21 | + "quorumdkgstatus ( detail_level )\n" |
| 22 | + "Return the status of the current DKG process of the active masternode.\n" |
| 23 | + "\nArguments:\n" |
| 24 | + "1. detail_level (number, optional, default=0) Detail level of output.\n" |
| 25 | + " 0=Only show counts. 1=Show member indexes. 2=Show member's ProTxHashes.\n" |
| 26 | + "\nExamples:\n" |
| 27 | + + HelpExampleRpc("quorumdkgstatus", "2") |
| 28 | + + HelpExampleCli("quorumdkgstatus", "") |
| 29 | + ); |
| 30 | + } |
| 31 | + |
| 32 | + int detailLevel = request.params.size() > 0 ? request.params[0].get_int() : 0; |
| 33 | + if (detailLevel < 0 || detailLevel > 2) { |
| 34 | + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("invalid detail_level %d", detailLevel)); |
| 35 | + } |
| 36 | + |
| 37 | + if (!fMasterNode || !activeMasternodeManager) { |
| 38 | + throw JSONRPCError(RPC_INVALID_PARAMETER, "This is not a (deterministic) masternode"); |
| 39 | + } |
| 40 | + |
| 41 | + llmq::CDKGDebugStatus status; |
| 42 | + llmq::quorumDKGDebugManager->GetLocalDebugStatus(status); |
| 43 | + |
| 44 | + auto ret = status.ToJson(detailLevel); |
| 45 | + |
| 46 | + const int tipHeight = WITH_LOCK(cs_main, return chainActive.Height(); ); |
| 47 | + |
| 48 | + UniValue minableCommitments(UniValue::VOBJ); |
| 49 | + for (const auto& p : Params().GetConsensus().llmqs) { |
| 50 | + auto& params = p.second; |
| 51 | + llmq::CFinalCommitment fqc; |
| 52 | + if (llmq::quorumBlockProcessor->GetMinableCommitment(params.type, tipHeight, fqc)) { |
| 53 | + UniValue obj(UniValue::VOBJ); |
| 54 | + fqc.ToJson(obj); |
| 55 | + minableCommitments.pushKV(params.name, obj); |
| 56 | + } |
| 57 | + } |
| 58 | + ret.pushKV("minableCommitments", minableCommitments); |
| 59 | + |
| 60 | + return ret; |
| 61 | +} |
| 62 | + |
| 63 | +static const CRPCCommand commands[] = |
| 64 | +{ // category name actor (function) okSafe argNames |
| 65 | + // -------------- ------------------------- --------------------- ------ -------- |
| 66 | + { "evo", "quorumdkgstatus", &quorumdkgstatus, true, {"detail_level"} }, |
| 67 | +}; |
| 68 | + |
| 69 | +void RegisterQuorumsRPCCommands(CRPCTable& tableRPC) |
| 70 | +{ |
| 71 | + for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) |
| 72 | + tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]); |
| 73 | +} |
0 commit comments