Skip to content

Commit

Permalink
fix masternode current rpc (#1640)
Browse files Browse the repository at this point in the history
GetNextMasternodeInQueueForPayment should not filter scheduled massternodes for it
  • Loading branch information
UdjinM6 authored Sep 27, 2017
1 parent 8c15f5f commit 0c1679e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/masternodeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ class CMasternodeMan
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);
Expand Down
7 changes: 3 additions & 4 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 0c1679e

Please sign in to comment.