Fix division by zero (#1310)

* Fix division by zero

* Fixes based on code review comments

* Fix nProjectedVotes value

* Set nProjectedVotes to 2000
This commit is contained in:
Tim Flynn 2017-02-03 04:17:47 -05:00 committed by UdjinM6
parent 1486acfb99
commit 3840d97027

View File

@ -996,9 +996,12 @@ void CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
// Testnet is ~40 times smaller in masternode count, but only ~1000 masternodes usually vote,
// so 1 obj on mainnet == ~10 objs or ~1000 votes on testnet. However we want to test a higher
// number of votes to make sure it's robust enough, so aim at 2000 votes per masternode per request.
// On mainnet we have 4K+ masternodes, so nMaxObjRequestsPerNode always evaluates to `1`.
// On mainnet nMaxObjRequestsPerNode is always set to 1.
int nMaxObjRequestsPerNode = 1;
size_t nProjectedVotes = 2000;
int nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / mnodeman.size()));
if(Params().NetworkIDString() != CBaseChainParams::MAIN) {
nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / std::max(1, mnodeman.size())));
}
std::vector<CGovernanceObject*> vpGovObjsTmp;
std::vector<CGovernanceObject*> vpGovObjsTriggersTmp;