mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Add "isValidMember" and "memberIndex" to "quorum memberof" and allow to specify quorum scan count (#3009)
* Add "isValidMember" and "memberIndex" to output of "quorum memberof" * Allow to specify how many quorums to scan for in "quorum memberof"
This commit is contained in:
parent
99824a8792
commit
9ac7a998be
@ -192,20 +192,29 @@ UniValue quorum_dkgstatus(const JSONRPCRequest& request)
|
||||
void quorum_memberof_help()
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"quorum memberof \"proTxHash\"\n"
|
||||
"quorum memberof \"proTxHash\" (quorumCount)\n"
|
||||
"Checks which quorums the given masternode is a member of.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"proTxHash\" (string, required) ProTxHash of the masternode.\n"
|
||||
"2. scanQuorumsCount (number, optional) Number of quorums to scan for. If not specified,\n"
|
||||
" the active quorum count for each specific quorum type is used."
|
||||
);
|
||||
}
|
||||
|
||||
UniValue quorum_memberof(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || (request.params.size() != 2)) {
|
||||
if (request.fHelp || (request.params.size() < 2 || request.params.size() > 3)) {
|
||||
quorum_memberof_help();
|
||||
}
|
||||
|
||||
uint256 protxHash = ParseHashV(request.params[1], "proTxHash");
|
||||
int scanQuorumsCount = -1;
|
||||
if (request.params.size() >= 3) {
|
||||
scanQuorumsCount = ParseInt32V(request.params[2], "scanQuorumsCount");
|
||||
if (scanQuorumsCount <= 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid scanQuorumsCount parameter");
|
||||
}
|
||||
}
|
||||
|
||||
const CBlockIndex* pindexTip;
|
||||
{
|
||||
@ -219,26 +228,25 @@ UniValue quorum_memberof(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "masternode not found");
|
||||
}
|
||||
|
||||
std::set<std::pair<Consensus::LLMQType, uint256>> quorumHashes;
|
||||
UniValue result(UniValue::VARR);
|
||||
|
||||
for (const auto& p : Params().GetConsensus().llmqs) {
|
||||
auto& params = p.second;
|
||||
auto quorums = llmq::quorumManager->ScanQuorums(params.type, params.signingActiveQuorumCount);
|
||||
size_t count = params.signingActiveQuorumCount;
|
||||
if (scanQuorumsCount != -1) {
|
||||
count = (size_t)scanQuorumsCount;
|
||||
}
|
||||
auto quorums = llmq::quorumManager->ScanQuorums(params.type, count);
|
||||
for (auto& quorum : quorums) {
|
||||
for (auto& m : quorum->members) {
|
||||
if (m->proTxHash == dmn->proTxHash) {
|
||||
quorumHashes.emplace(params.type, quorum->qc.quorumHash);
|
||||
}
|
||||
if (quorum->IsMember(dmn->proTxHash)) {
|
||||
auto json = BuildQuorumInfo(quorum, false, false);
|
||||
json.push_back(Pair("isValidMember", quorum->IsValidMember(dmn->proTxHash)));
|
||||
json.push_back(Pair("memberIndex", quorum->GetMemberIndex(dmn->proTxHash)));
|
||||
result.push_back(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UniValue result(UniValue::VARR);
|
||||
for (auto& p : quorumHashes) {
|
||||
auto quorum = llmq::quorumManager->GetQuorum(p.first, p.second);
|
||||
assert(quorum);
|
||||
result.push_back(BuildQuorumInfo(quorum, false, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user