Skip to content

Commit aae961c

Browse files
committed
RPC: Implement quorumdkgstatus command
1 parent 8341489 commit aae961c

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ set(SERVER_SOURCES
255255
./src/rpc/net.cpp
256256
./src/rpc/rawtransaction.cpp
257257
./src/rpc/rpcevo.cpp
258+
./src/rpc/rpcquorums.cpp
258259
./src/rpc/server.cpp
259260
./src/script/sigcache.cpp
260261
./src/script/ismine.cpp

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ libbitcoin_server_a_SOURCES = \
401401
rpc/net.cpp \
402402
rpc/rawtransaction.cpp \
403403
rpc/rpcevo.cpp \
404+
rpc/rpcquorums.cpp \
404405
rpc/server.cpp \
405406
script/sigcache.cpp \
406407
script/ismine.cpp \

src/rpc/register.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ void RegisterMasternodeRPCCommands(CRPCTable& tableRPC);
2525
void RegisterBudgetRPCCommands(CRPCTable& tableRPC);
2626
/** Register Evo RPC commands */
2727
void RegisterEvoRPCCommands(CRPCTable &tableRPC);
28+
/** Register Quorums RPC commands */
29+
void RegisterQuorumsRPCCommands(CRPCTable &tableRPC);
2830

2931
static inline void RegisterAllCoreRPCCommands(CRPCTable& tableRPC)
3032
{
@@ -36,6 +38,7 @@ static inline void RegisterAllCoreRPCCommands(CRPCTable& tableRPC)
3638
RegisterMasternodeRPCCommands(tableRPC);
3739
RegisterBudgetRPCCommands(tableRPC);
3840
RegisterEvoRPCCommands(tableRPC);
41+
RegisterQuorumsRPCCommands(tableRPC);
3942
}
4043

4144
#endif

src/rpc/rpcquorums.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)