Fix wrong total MN count in UI and "masternode count" RPC (#2527)
* Use CountMasternodes() in ClientModel::getMasternodeCountString * Use CountMasternodes() for total count in masternode_count * Fix CountMasternodes() to give correct number of masternodes with spork15 enabled Also change CountEnabled to not call CountMasternodes anymore but instead have its own implementation which uses GetValidMNsCount instead of GetAllMNsCount * Apply review suggestions
This commit is contained in:
parent
8f8878a94f
commit
2161199210
@ -455,7 +455,7 @@ int CMasternodeMan::CountMasternodes(int nProtocolVersion)
|
|||||||
|
|
||||||
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
||||||
auto mnList = deterministicMNManager->GetListAtChainTip();
|
auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
nCount = (int)mnList.GetValidMNsCount();
|
nCount = (int)mnList.GetAllMNsCount();
|
||||||
} else {
|
} else {
|
||||||
for (const auto& mnpair : mapMasternodes) {
|
for (const auto& mnpair : mapMasternodes) {
|
||||||
if(mnpair.second.nProtocolVersion < nProtocolVersion) continue;
|
if(mnpair.second.nProtocolVersion < nProtocolVersion) continue;
|
||||||
@ -469,16 +469,18 @@ int CMasternodeMan::CountEnabled(int nProtocolVersion)
|
|||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
if (deterministicMNManager->IsDeterministicMNsSporkActive())
|
|
||||||
return CountMasternodes(nProtocolVersion);
|
|
||||||
|
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
|
nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
|
||||||
|
|
||||||
|
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
||||||
|
auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
|
nCount = (int)mnList.GetValidMNsCount();
|
||||||
|
} else {
|
||||||
for (const auto& mnpair : mapMasternodes) {
|
for (const auto& mnpair : mapMasternodes) {
|
||||||
if (mnpair.second.nProtocolVersion < nProtocolVersion || !mnpair.second.IsEnabled()) continue;
|
if (mnpair.second.nProtocolVersion < nProtocolVersion || !mnpair.second.IsEnabled()) continue;
|
||||||
nCount++;
|
nCount++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nCount;
|
return nCount;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ QString ClientModel::getMasternodeCountString() const
|
|||||||
{
|
{
|
||||||
// return tr("Total: %1 (PS compatible: %2 / Enabled: %3) (IPv4: %4, IPv6: %5, TOR: %6)").arg(QString::number((int)mnodeman.size()))
|
// return tr("Total: %1 (PS compatible: %2 / Enabled: %3) (IPv4: %4, IPv6: %5, TOR: %6)").arg(QString::number((int)mnodeman.size()))
|
||||||
return tr("Total: %1 (PS compatible: %2 / Enabled: %3)")
|
return tr("Total: %1 (PS compatible: %2 / Enabled: %3)")
|
||||||
.arg(QString::number((int)mnodeman.size()))
|
.arg(QString::number((int)mnodeman.CountMasternodes(0)))
|
||||||
.arg(QString::number((int)mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)))
|
.arg(QString::number((int)mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)))
|
||||||
.arg(QString::number((int)mnodeman.CountEnabled()));
|
.arg(QString::number((int)mnodeman.CountEnabled()));
|
||||||
// .arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
|
// .arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
|
||||||
|
@ -225,13 +225,12 @@ UniValue masternode_count(const JSONRPCRequest& request)
|
|||||||
masternode_count_help();
|
masternode_count_help();
|
||||||
|
|
||||||
int nCount;
|
int nCount;
|
||||||
int total;
|
int total = mnodeman.CountMasternodes(0);
|
||||||
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
||||||
nCount = total = mnodeman.CountEnabled();
|
nCount = mnodeman.CountEnabled();
|
||||||
} else {
|
} else {
|
||||||
masternode_info_t mnInfo;
|
masternode_info_t mnInfo;
|
||||||
mnodeman.GetNextMasternodeInQueueForPayment(true, nCount, mnInfo);
|
mnodeman.GetNextMasternodeInQueueForPayment(true, nCount, mnInfo);
|
||||||
total = mnodeman.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ps = mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION);
|
int ps = mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION);
|
||||||
|
Loading…
Reference in New Issue
Block a user