Commit 2b837143 authored by Evan Duffield's avatar Evan Duffield
Browse files

Fix payment cycle when network is in the process of updating

parent 655a78ac
Showing with 23 additions and 11 deletions
+23 -11
......@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 12)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 46)
define(_CLIENT_VERSION_BUILD, 47)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2015)
AC_INIT([Dash Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@dashpay.io],[dash])
......
......@@ -17,7 +17,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 12
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 46
#define CLIENT_VERSION_BUILD 47
//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
......
......@@ -686,8 +686,8 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
LogPrintf("CMasternodePayments::ProcessBlock() Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.ToString().c_str());
// pay to the oldest MN that still had no payment but its input is old enough and it was active long enough
CMasternode *pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true);
if(pmn == NULL) pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, false); // if no results, look for any node with a newer sigTime
int nCount = 0;
CMasternode *pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount);
if(pmn != NULL)
{
......
......@@ -414,9 +414,10 @@ CMasternode *CMasternodeMan::Find(const CPubKey &pubKeyMasternode)
//
// Deterministically select the oldest/best masternode to pay on the network
//
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime)
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount)
{
LOCK(cs);
nCount = 0;
CMasternode *pBestMasternode = NULL;
std::vector<pair<int64_t, CTxIn> > vecMasternodeLastPaid;
......@@ -444,8 +445,12 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
if(mn.GetMasternodeInputAge() < nMnCount) continue;
vecMasternodeLastPaid.push_back(make_pair(mn.SecondsSincePayment(), mn.vin));
nCount++;
}
//when the network is in the process of upgrading, don't penalize nodes that recently restarted
if(fFilterSigTime && nCount < nMnCount/3) return GetNextMasternodeInQueueForPayment(nBlockHeight, false, nCount);
// Sort them low to high
sort(vecMasternodeLastPaid.rbegin(), vecMasternodeLastPaid.rend(), CompareLastPaid());
......@@ -454,7 +459,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
// -- 1/100 payments should be a double payment on mainnet - (1/(3000/10))*2
// -- (chance per block * chances before IsScheduled will fire)
int nTenthNetwork = CountEnabled()/10;
int nCount = 0;
int nCountTenth = 0;
uint256 nHigh = 0;
BOOST_FOREACH (PAIRTYPE(int64_t, CTxIn)& s, vecMasternodeLastPaid){
CMasternode* pmn = Find(s.second);
......@@ -465,7 +470,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
nHigh = n;
pBestMasternode = pmn;
}
nCount++;
nCountTenth++;
if(nCount >= nTenthNetwork) break;
}
return pBestMasternode;
......
......@@ -116,7 +116,7 @@ public:
CMasternode* Find(const CPubKey& pubKeyMasternode);
/// Find an entry in the masternode list that is next to be paid
CMasternode* GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime=true);
CMasternode* GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount);
/// Find a random entry
CMasternode* FindRandomNotInVec(std::vector<CTxIn> &vecToExclude, int protocolVersion = -1);
......
......@@ -134,7 +134,7 @@ Value masternode(const Array& params, bool fHelp)
"1. \"command\" (string or set of strings, required) The command to execute\n"
"2. \"passphrase\" (string, optional) The wallet passphrase\n"
"\nAvailable commands:\n"
" count - Print number of all known masternodes (optional: 'ds', 'enabled', 'all')\n"
" count - Print number of all known masternodes (optional: 'ds', 'enabled', 'all', 'qualify')\n"
" current - Print info on current masternode winner\n"
" debug - Print masternode status\n"
" genkey - Generate new masternodeprivkey\n"
......@@ -186,12 +186,19 @@ Value masternode(const Array& params, bool fHelp)
}
if (params.size() == 2)
{
int nCount = 0;
if(chainActive.Tip())
mnodeman.GetNextMasternodeInQueueForPayment(chainActive.Tip()->nHeight, true, nCount);
if(params[1] == "ds") return mnodeman.CountEnabled(MIN_POOL_PEER_PROTO_VERSION);
if(params[1] == "enabled") return mnodeman.CountEnabled();
if(params[1] == "all") return strprintf("Total: %d (DS Compatible: %d / Enabled: %d)",
if(params[1] == "qualify") return nCount;
if(params[1] == "all") return strprintf("Total: %d (DS Compatible: %d / Enabled: %d / Qualify: %d)",
mnodeman.size(),
mnodeman.CountEnabled(MIN_POOL_PEER_PROTO_VERSION),
mnodeman.CountEnabled());
mnodeman.CountEnabled(),
nCount);
}
return mnodeman.size();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment