fix masternode current rpc (#1640)

GetNextMasternodeInQueueForPayment should not filter scheduled massternodes for it
This commit is contained in:
UdjinM6 2017-09-27 20:43:03 +03:00 committed by GitHub
parent 8c15f5f878
commit 0c1679e58c
4 changed files with 12 additions and 13 deletions

View File

@ -272,7 +272,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int nBlockH
// no masternode detected...
int nCount = 0;
masternode_info_t mnInfo;
if(!mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount, mnInfo)) {
if(!mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, true, nCount, mnInfo)) {
// ...and we can't calculate it on our own
LogPrintf("CMasternodePayments::FillBlockPayee -- Failed to detect masternode to pay\n");
return;
@ -744,7 +744,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight, CConnman& connman)
int nCount = 0;
masternode_info_t mnInfo;
if (!mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount, mnInfo)) {
if (!mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, true, nCount, mnInfo)) {
LogPrintf("CMasternodePayments::ProcessBlock -- ERROR: Failed to find masternode to pay\n");
return false;
}

View File

@ -482,12 +482,12 @@ bool CMasternodeMan::Has(const COutPoint& outpoint)
//
// Deterministically select the oldest/best masternode to pay on the network
//
bool CMasternodeMan::GetNextMasternodeInQueueForPayment(bool fFilterSigTime, int& nCountRet, masternode_info_t& mnInfoRet)
bool CMasternodeMan::GetNextMasternodeInQueueForPayment(bool fFilterSigTime, bool fFilterScheduled, int& nCountRet, masternode_info_t& mnInfoRet)
{
return GetNextMasternodeInQueueForPayment(nCachedBlockHeight, fFilterSigTime, nCountRet, mnInfoRet);
return GetNextMasternodeInQueueForPayment(nCachedBlockHeight, fFilterSigTime, fFilterScheduled, nCountRet, mnInfoRet);
}
bool CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCountRet, masternode_info_t& mnInfoRet)
bool CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, bool fFilterScheduled, int& nCountRet, masternode_info_t& mnInfoRet)
{
mnInfoRet = masternode_info_t();
nCountRet = 0;
@ -515,7 +515,7 @@ bool CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool f
if(mnpair.second.nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto()) continue;
//it's in the list (up to 8 entries ahead of current block to allow propagation) -- so let's skip it
if(mnpayments.IsScheduled(mnpair.second, nBlockHeight)) continue;
if(fFilterScheduled && mnpayments.IsScheduled(mnpair.second, nBlockHeight)) continue;
//it's too new, wait for a cycle
if(fFilterSigTime && mnpair.second.sigTime + (nMnCount*2.6*60) > GetAdjustedTime()) continue;
@ -530,7 +530,7 @@ bool CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool f
//when the network is in the process of upgrading, don't penalize nodes that recently restarted
if(fFilterSigTime && nCountRet < nMnCount/3)
return GetNextMasternodeInQueueForPayment(nBlockHeight, false, nCountRet, mnInfoRet);
return GetNextMasternodeInQueueForPayment(nBlockHeight, false, fFilterScheduled, nCountRet, mnInfoRet);
// Sort them low to high
sort(vecMasternodeLastPaid.begin(), vecMasternodeLastPaid.end(), CompareLastPaidBlock());

View File

@ -166,9 +166,9 @@ public:
bool GetMasternodeInfo(const CScript& payee, masternode_info_t& mnInfoRet);
/// Find an entry in the masternode list that is next to be paid
bool GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCountRet, masternode_info_t& mnInfoRet);
bool GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, bool fFilterScheduled, int& nCountRet, masternode_info_t& mnInfoRet);
/// Same as above but use current block height
bool GetNextMasternodeInQueueForPayment(bool fFilterSigTime, int& nCountRet, masternode_info_t& mnInfoRet);
bool GetNextMasternodeInQueueForPayment(bool fFilterSigTime, bool fFilterScheduled, int& nCountRet, masternode_info_t& mnInfoRet);
/// Find a random entry
masternode_info_t FindRandomNotInVec(const std::vector<COutPoint> &vecToExclude, int nProtocolVersion = -1);

View File

@ -125,7 +125,7 @@ UniValue masternode(const UniValue& params, bool fHelp)
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" list-conf - Print masternode.conf in JSON format\n"
" winner - Print info on next masternode winner to vote for\n"
" winner - Print info on next masternode winner to vote for (calculated locally)\n"
" winners - Print list of masternode winners\n"
);
@ -176,7 +176,7 @@ UniValue masternode(const UniValue& params, bool fHelp)
int nCount;
masternode_info_t mnInfo;
mnodeman.GetNextMasternodeInQueueForPayment(true, nCount, mnInfo);
mnodeman.GetNextMasternodeInQueueForPayment(true, true, nCount, mnInfo);
if (strMode == "qualify")
return nCount;
@ -199,8 +199,7 @@ UniValue masternode(const UniValue& params, bool fHelp)
}
nHeight = pindex->nHeight + (strCommand == "current" ? 1 : 10);
mnodeman.UpdateLastPaid(pindex);
if(!mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, nCount, mnInfo))
if (!mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, false, nCount, mnInfo))
return "unknown";
UniValue obj(UniValue::VOBJ);