mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Implement "quorum selectquorum" RPC
This commit is contained in:
parent
5edbeafcea
commit
80533f6c0d
@ -13,6 +13,7 @@
|
||||
#include <llmq/quorums_debug.h>
|
||||
#include <llmq/quorums_dkgsession.h>
|
||||
#include <llmq/quorums_signing.h>
|
||||
#include <llmq/quorums_signing_shares.h>
|
||||
|
||||
void quorum_list_help()
|
||||
{
|
||||
@ -377,6 +378,54 @@ UniValue quorum_sigs_cmd(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
|
||||
void quorum_selectquorum_help()
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"quorum selectquorum llmqType \"id\"\n"
|
||||
"Returns the quorum that would/should sign a request\n"
|
||||
"\nArguments:\n"
|
||||
"1. llmqType (int, required) LLMQ type.\n"
|
||||
"2. \"id\" (string, required) Request id.\n"
|
||||
);
|
||||
}
|
||||
|
||||
UniValue quorum_selectquorum(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 3) {
|
||||
quorum_selectquorum_help();
|
||||
}
|
||||
|
||||
Consensus::LLMQType llmqType = (Consensus::LLMQType)ParseInt32V(request.params[1], "llmqType");
|
||||
if (!Params().GetConsensus().llmqs.count(llmqType)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid LLMQ type");
|
||||
}
|
||||
|
||||
uint256 id = ParseHashV(request.params[2], "id");
|
||||
|
||||
int tipHeight;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
tipHeight = chainActive.Height();
|
||||
}
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
|
||||
auto quorum = llmq::quorumSigningManager->SelectQuorumForSigning(llmqType, tipHeight, id);
|
||||
if (!quorum) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "no quorums active");
|
||||
}
|
||||
ret.push_back(Pair("quorumHash", quorum->qc.quorumHash.ToString()));
|
||||
|
||||
UniValue recoveryMembers(UniValue::VARR);
|
||||
for (int i = 0; i < quorum->params.recoveryMembers; i++) {
|
||||
auto dmn = llmq::quorumSigSharesManager->SelectMemberForRecovery(quorum, id, i);
|
||||
recoveryMembers.push_back(dmn->proTxHash.ToString());
|
||||
}
|
||||
ret.push_back(Pair("recoveryMembers", recoveryMembers));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void quorum_dkgsimerror_help()
|
||||
{
|
||||
throw std::runtime_error(
|
||||
@ -427,6 +476,7 @@ UniValue quorum_dkgsimerror(const JSONRPCRequest& request)
|
||||
" hasrecsig - Test if a valid recovered signature is present\n"
|
||||
" getrecsig - Get a recovered signature\n"
|
||||
" isconflicting - Test if a conflict exists\n"
|
||||
" selectquorum - Return the quorum that would/should sign a request\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -451,6 +501,8 @@ UniValue quorum(const JSONRPCRequest& request)
|
||||
return quorum_memberof(request);
|
||||
} else if (command == "sign" || command == "hasrecsig" || command == "getrecsig" || command == "isconflicting") {
|
||||
return quorum_sigs_cmd(request);
|
||||
} else if (command == "selectquorum") {
|
||||
return quorum_selectquorum(request);
|
||||
} else if (command == "dkgsimerror") {
|
||||
return quorum_dkgsimerror(request);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user