mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
feat(rpc): Ability to filter HPMNs in masternodelist and protx list rpcs (#5447)
## Issue being fixed or feature implemented Added the filter `hpmn` for both `masternodelist` and `protx list` rpcs. ## What was done? ## How Has This Been Tested? Calling this RPC on Testnet. ## Breaking Changes ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --------- Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
parent
950fdde4e8
commit
49e024338a
6
doc/release-notes-5447.md
Normal file
6
doc/release-notes-5447.md
Normal file
@ -0,0 +1,6 @@
|
||||
Updated RPCs
|
||||
--------
|
||||
|
||||
- `masternodelist`: New mode `hpmn` filters only HPMNs.
|
||||
- `protx list`: New type `hpmn` filters only HPMNs.
|
||||
|
@ -1204,6 +1204,7 @@ static void protx_list_help(const JSONRPCRequest& request)
|
||||
" registered - List all ProTx which are registered at the given chain height.\n"
|
||||
" This will also include ProTx which failed PoSe verification.\n"
|
||||
" valid - List only ProTx which are active/valid at the given chain height.\n"
|
||||
" hpmn - List only ProTx corresponding to HPMNs at the given chain height.\n"
|
||||
#ifdef ENABLE_WALLET
|
||||
" wallet - List only ProTx which are found in your wallet at the given chain height.\n"
|
||||
" This will also include ProTx which failed PoSe verification.\n"
|
||||
@ -1349,7 +1350,7 @@ static UniValue protx_list(const JSONRPCRequest& request)
|
||||
}
|
||||
});
|
||||
#endif
|
||||
} else if (type == "valid" || type == "registered") {
|
||||
} else if (type == "valid" || type == "registered" || type == "hpmn") {
|
||||
if (request.params.size() > 3) {
|
||||
protx_list_help(request);
|
||||
}
|
||||
@ -1365,7 +1366,9 @@ static UniValue protx_list(const JSONRPCRequest& request)
|
||||
|
||||
CDeterministicMNList mnList = deterministicMNManager->GetListForBlock(::ChainActive()[height]);
|
||||
bool onlyValid = type == "valid";
|
||||
bool onlyHPMN = type == "hpmn";
|
||||
mnList.ForEachMN(onlyValid, [&](const auto& dmn) {
|
||||
if (onlyHPMN && dmn.nType != MnType::HighPerformance) return;
|
||||
ret.push_back(BuildDMNListEntry(wallet.get(), dmn, detailed));
|
||||
});
|
||||
} else {
|
||||
|
@ -37,6 +37,7 @@ static void masternode_list_help(const JSONRPCRequest& request)
|
||||
"Available modes:\n"
|
||||
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
|
||||
" recent - Print info in JSON format for active and recently banned masternodes (can be additionally filtered, partial match)\n"
|
||||
" hpmn - Print info in JSON format for HPMNs only\n"
|
||||
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
|
||||
" (can be additionally filtered, partial match)\n"
|
||||
" info - Print info in format 'status payee IP'\n"
|
||||
@ -581,7 +582,7 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
||||
strMode != "owneraddress" && strMode != "votingaddress" &&
|
||||
strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
|
||||
strMode != "payee" && strMode != "pubkeyoperator" &&
|
||||
strMode != "status" && strMode != "recent"))
|
||||
strMode != "status" && strMode != "recent" && strMode != "hpmn"))
|
||||
{
|
||||
masternode_list_help(request);
|
||||
}
|
||||
@ -609,6 +610,7 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
||||
};
|
||||
|
||||
bool showRecentMnsOnly = strMode == "recent";
|
||||
bool showHPMNsOnly = strMode == "hpmn";
|
||||
int tipHeight = WITH_LOCK(cs_main, return ::ChainActive().Tip()->nHeight);
|
||||
mnList.ForEachMN(false, [&](auto& dmn) {
|
||||
if (showRecentMnsOnly && mnList.IsMNPoSeBanned(dmn)) {
|
||||
@ -616,6 +618,9 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (showHPMNsOnly && dmn.nType != MnType::HighPerformance) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strOutpoint = dmn.collateralOutpoint.ToStringShort();
|
||||
Coin coin;
|
||||
@ -663,7 +668,7 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
||||
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
|
||||
strOutpoint.find(strFilter) == std::string::npos) return;
|
||||
obj.pushKV(strOutpoint, strInfo);
|
||||
} else if (strMode == "json" || strMode == "recent") {
|
||||
} else if (strMode == "json" || strMode == "recent" || strMode == "hpmn") {
|
||||
std::ostringstream streamInfo;
|
||||
streamInfo << dmn.proTxHash.ToString() << " " <<
|
||||
dmn.pdmnState->addr.ToString() << " " <<
|
||||
|
Loading…
Reference in New Issue
Block a user