mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
feat(rpc): masternode status and count RPCs adjusted for HPMNs (#5206)
## Issue being fixed or feature implemented ## What was done? - `masternode status` now returns the type as well - `masternode count` now returns in addition total and total enabled MNs per type. ## How Has This Been Tested? Added functional tests ## 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 - [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
33703a5f2f
commit
a3918451d0
5
doc/release-notes-5206.md
Normal file
5
doc/release-notes-5206.md
Normal file
@ -0,0 +1,5 @@
|
||||
Updated RPCs
|
||||
--------
|
||||
|
||||
- `masternode` mode `status` now returns the type of the masternode.
|
||||
- `masternode` mode `count` now returns a detailed summary of total and enabled masternodes per type.
|
@ -230,6 +230,11 @@ public:
|
||||
return ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::HighPerformance; });
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t GetValidHPMNsCount() const
|
||||
{
|
||||
return ranges::count_if(mnMap, [](const auto& p) { return p.second->nType == MnType::HighPerformance && IsMNValid(*p.second); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a callback on all masternodes in the mnList. This will pass a reference
|
||||
* of each masternode to the callback function. This should be preferred over ForEachMNShared.
|
||||
|
@ -112,6 +112,23 @@ static UniValue masternode_count(const JSONRPCRequest& request)
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("total", total);
|
||||
obj.pushKV("enabled", enabled);
|
||||
|
||||
int hpmn_total = mnList.GetAllHPMNsCount();
|
||||
int hpmn_enabled = mnList.GetValidHPMNsCount();
|
||||
|
||||
UniValue hpmnObj(UniValue::VOBJ);
|
||||
hpmnObj.pushKV("total", hpmn_total);
|
||||
hpmnObj.pushKV("enabled", hpmn_enabled);
|
||||
|
||||
UniValue regularObj(UniValue::VOBJ);
|
||||
regularObj.pushKV("total", total - hpmn_total);
|
||||
regularObj.pushKV("enabled", enabled - hpmn_enabled);
|
||||
|
||||
UniValue detailedObj(UniValue::VOBJ);
|
||||
detailedObj.pushKV("regular", regularObj);
|
||||
detailedObj.pushKV("hpmn", hpmnObj);
|
||||
obj.pushKV("detailed", detailedObj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -247,6 +264,7 @@ static UniValue masternode_status(const JSONRPCRequest& request)
|
||||
}
|
||||
if (dmn) {
|
||||
mnObj.pushKV("proTxHash", dmn->proTxHash.ToString());
|
||||
mnObj.pushKV("type", std::string(GetMnType(dmn->nType).description));
|
||||
mnObj.pushKV("collateralHash", dmn->collateralOutpoint.hash.ToString());
|
||||
mnObj.pushKV("collateralIndex", (int)dmn->collateralOutpoint.n);
|
||||
UniValue stateObj;
|
||||
|
@ -46,6 +46,8 @@ class LLMQHPMNTest(DashTestFramework):
|
||||
self.log.info("Test that HPMN registration is rejected before v19")
|
||||
self.test_hpmn_is_rejected_before_v19()
|
||||
|
||||
self.test_masternode_count(expected_mns_count=4, expected_hpmns_count=0)
|
||||
|
||||
self.activate_v19(expected_activation_height=900)
|
||||
self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount()))
|
||||
|
||||
@ -64,6 +66,7 @@ class LLMQHPMNTest(DashTestFramework):
|
||||
hpmn_protxhash_list.append(hpmn_info.proTxHash)
|
||||
self.nodes[0].generate(8)
|
||||
self.sync_blocks(self.nodes)
|
||||
self.test_masternode_count(expected_mns_count=4, expected_hpmns_count=i+1)
|
||||
self.test_hpmn_update_service(hpmn_info)
|
||||
|
||||
self.log.info("Test llmq_platform are formed only with HPMNs")
|
||||
@ -189,6 +192,13 @@ class LLMQHPMNTest(DashTestFramework):
|
||||
self.log.info("protx_hpmn rejected")
|
||||
assert_equal(protx_success, False)
|
||||
|
||||
def test_masternode_count(self, expected_mns_count, expected_hpmns_count):
|
||||
mn_count = self.nodes[0].masternode('count')
|
||||
assert_equal(mn_count['total'], expected_mns_count + expected_hpmns_count)
|
||||
detailed_count = mn_count['detailed']
|
||||
assert_equal(detailed_count['regular']['total'], expected_mns_count)
|
||||
assert_equal(detailed_count['hpmn']['total'], expected_hpmns_count)
|
||||
|
||||
def test_hpmn_update_service(self, hpmn_info):
|
||||
funds_address = self.nodes[0].getnewaddress()
|
||||
operator_reward_address = self.nodes[0].getnewaddress()
|
||||
|
Loading…
Reference in New Issue
Block a user