mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
feat(rpc): Hide old banned mns by default (#5125)
<!-- *** Please remove the following help text before submitting: *** Provide a general summary of your changes in the Title above Pull requests without a rationale and clear improvement may be closed immediately. Please provide clear motivation for your patch and explain how it improves Dash Core user experience or Dash Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Dash Core, if possible. --> ## Issue being fixed or feature implemented <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> ## What was done? <!--- Describe your changes in detail --> It was requested by service desk to hide old banned masternodes when calling rpc `masternodelist`. The period from which a masternode is considered old banned is more than a `SuperblockCycle`. | Network | SuperblockCycle | | ------------- |:-------------:| | Mainnet | 16616 | | Testnet | 24 | | Devnet | 24 | | Regtest | 10 | The new mode `recent` was added to in order to hide old banned masternodes. Note: If the mode `recent` is used, then the reply mode is `JSON` (can be additionally filtered) ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Breaking Changes <!--- Please describe any breaking changes your code introduces --> ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **For repository code-owners and collaborators only** - [x] I have assigned this pull request to a milestone
This commit is contained in:
parent
6ea6f3f30f
commit
a37e196dd0
4
doc/release-notes-5125.md
Normal file
4
doc/release-notes-5125.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Updated RPCs
|
||||||
|
--------
|
||||||
|
|
||||||
|
- `masternodelist` New mode `recent` was added in order to hide banned masternodes for more than one `SuperblockCycle`. If the mode `recent` is used, then the reply mode is JSON (can be additionally filtered)
|
@ -35,6 +35,7 @@ static void masternode_list_help(const JSONRPCRequest& request)
|
|||||||
"Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n"
|
"Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n"
|
||||||
"Available modes:\n"
|
"Available modes:\n"
|
||||||
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\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"
|
||||||
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
|
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
|
||||||
" (can be additionally filtered, partial match)\n"
|
" (can be additionally filtered, partial match)\n"
|
||||||
" info - Print info in format 'status payee IP'\n"
|
" info - Print info in format 'status payee IP'\n"
|
||||||
@ -560,7 +561,7 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
|||||||
strMode != "owneraddress" && strMode != "votingaddress" &&
|
strMode != "owneraddress" && strMode != "votingaddress" &&
|
||||||
strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
|
strMode != "lastpaidtime" && strMode != "lastpaidblock" &&
|
||||||
strMode != "payee" && strMode != "pubkeyoperator" &&
|
strMode != "payee" && strMode != "pubkeyoperator" &&
|
||||||
strMode != "status"))
|
strMode != "status" && strMode != "recent"))
|
||||||
{
|
{
|
||||||
masternode_list_help(request);
|
masternode_list_help(request);
|
||||||
}
|
}
|
||||||
@ -587,7 +588,15 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
|||||||
return (int)pindex->nTime;
|
return (int)pindex->nTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool showRecentMnsOnly = strMode == "recent";
|
||||||
|
int tipHeight = WITH_LOCK(cs_main, return ::ChainActive().Tip()->nHeight);
|
||||||
mnList.ForEachMN(false, [&](auto& dmn) {
|
mnList.ForEachMN(false, [&](auto& dmn) {
|
||||||
|
if (showRecentMnsOnly && mnList.IsMNPoSeBanned(dmn)) {
|
||||||
|
if (tipHeight - dmn.pdmnState->GetBannedHeight() > Params().GetConsensus().nSuperblockCycle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string strOutpoint = dmn.collateralOutpoint.ToStringShort();
|
std::string strOutpoint = dmn.collateralOutpoint.ToStringShort();
|
||||||
Coin coin;
|
Coin coin;
|
||||||
std::string collateralAddressStr = "UNKNOWN";
|
std::string collateralAddressStr = "UNKNOWN";
|
||||||
@ -634,7 +643,7 @@ static UniValue masternodelist(const JSONRPCRequest& request)
|
|||||||
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
|
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
|
||||||
strOutpoint.find(strFilter) == std::string::npos) return;
|
strOutpoint.find(strFilter) == std::string::npos) return;
|
||||||
obj.pushKV(strOutpoint, strInfo);
|
obj.pushKV(strOutpoint, strInfo);
|
||||||
} else if (strMode == "json") {
|
} else if (strMode == "json" || strMode == "recent") {
|
||||||
std::ostringstream streamInfo;
|
std::ostringstream streamInfo;
|
||||||
streamInfo << dmn.proTxHash.ToString() << " " <<
|
streamInfo << dmn.proTxHash.ToString() << " " <<
|
||||||
dmn.pdmnState->addr.ToString() << " " <<
|
dmn.pdmnState->addr.ToString() << " " <<
|
||||||
|
Loading…
Reference in New Issue
Block a user