masternode voting improvements

This commit is contained in:
Evan Duffield 2015-03-20 20:34:36 -07:00
parent 1cf72dea8c
commit 649937dc4f
3 changed files with 12 additions and 2 deletions

View File

@ -194,6 +194,8 @@ CMasternode::CMasternode(CService newAddr, CTxIn newVin, CPubKey newPubkey, std:
nScanningErrorCount = 0; nScanningErrorCount = 0;
donationAddress = newDonationAddress; donationAddress = newDonationAddress;
donationPercentage = newDonationPercentage; donationPercentage = newDonationPercentage;
nVote = 0;
lastVote = 0;
} }
// //

View File

@ -114,6 +114,8 @@ public:
swap(first.nLastDsq, second.nLastDsq); swap(first.nLastDsq, second.nLastDsq);
swap(first.donationAddress, second.donationAddress); swap(first.donationAddress, second.donationAddress);
swap(first.donationPercentage, second.donationPercentage); swap(first.donationPercentage, second.donationPercentage);
swap(first.nVote, second.nVote);
swap(first.lastVote, second.lastVote);
} }
CMasternode& operator=(CMasternode from) CMasternode& operator=(CMasternode from)
@ -158,6 +160,8 @@ public:
READWRITE(nLastDsq); READWRITE(nLastDsq);
READWRITE(donationAddress); READWRITE(donationAddress);
READWRITE(donationPercentage); READWRITE(donationPercentage);
READWRITE(nVote);
READWRITE(lastVote);
} }
) )

View File

@ -714,8 +714,12 @@ Value masternodelist(const Array& params, bool fHelp)
std::string strStatus = "ABSTAIN"; std::string strStatus = "ABSTAIN";
//voting lasts 7 days, ignore the last vote if it was older than that
if((GetAdjustedTime() - mn.lastVote) < (60*60*8))
{
if(mn.nVote == -1) strStatus = "NAY"; if(mn.nVote == -1) strStatus = "NAY";
if(mn.nVote == 1) strStatus = "YAY"; if(mn.nVote == 1) strStatus = "YEA";
}
obj.push_back(Pair(strAddr, strStatus.c_str())); obj.push_back(Pair(strAddr, strStatus.c_str()));
} else if (strMode == "activeseconds") { } else if (strMode == "activeseconds") {