Governance masternode notification bug fixes (#1270)

* Flag governance items when MN's are removed

* Remove old broken update mechanism

* Do not flag MN state changes which are irrelevant to validity

* Call AddGovernanceVote
This commit is contained in:
Tim Flynn 2017-01-18 10:24:19 -05:00 committed by UdjinM6
parent 5254255a0a
commit 4b7bd6be8f
3 changed files with 2 additions and 14 deletions

View File

@ -170,6 +170,7 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom,
} }
voteInstance = vote_instance_t(vote.GetOutcome(), nVoteTimeUpdate); voteInstance = vote_instance_t(vote.GetOutcome(), nVoteTimeUpdate);
fileVotes.AddVote(vote); fileVotes.AddVote(vote);
mnodeman.AddGovernanceVote(vote.GetVinMasternode(), vote.GetParentHash());
fDirtyCache = true; fDirtyCache = true;
return true; return true;
} }

View File

@ -219,8 +219,6 @@ void CMasternode::Check(bool fForce)
nActiveState = MASTERNODE_UPDATE_REQUIRED; nActiveState = MASTERNODE_UPDATE_REQUIRED;
if(nActiveStatePrev != nActiveState) { if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
// RESCAN AFFECTED VOTES
FlagGovernanceItemsAsDirty();
} }
return; return;
} }
@ -259,8 +257,6 @@ void CMasternode::Check(bool fForce)
nActiveState = MASTERNODE_NEW_START_REQUIRED; nActiveState = MASTERNODE_NEW_START_REQUIRED;
if(nActiveStatePrev != nActiveState) { if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
// RESCAN AFFECTED VOTES
FlagGovernanceItemsAsDirty();
} }
return; return;
} }
@ -283,8 +279,6 @@ void CMasternode::Check(bool fForce)
nActiveState = MASTERNODE_EXPIRED; nActiveState = MASTERNODE_EXPIRED;
if(nActiveStatePrev != nActiveState) { if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
// RESCAN AFFECTED VOTES
FlagGovernanceItemsAsDirty();
} }
return; return;
} }
@ -962,14 +956,6 @@ void CMasternode::UpdateWatchdogVoteTime()
*/ */
void CMasternode::FlagGovernanceItemsAsDirty() void CMasternode::FlagGovernanceItemsAsDirty()
{ {
std::map<uint256, int>::iterator it = mapGovernanceObjectsVotedOn.begin();
while(it != mapGovernanceObjectsVotedOn.end()){
CGovernanceObject *pObj = governance.FindGovernanceObject((*it).first);
if(pObj) pObj->InvalidateVoteCache();
++it;
}
std::vector<uint256> vecDirty; std::vector<uint256> vecDirty;
{ {
std::map<uint256, int>::iterator it = mapGovernanceObjectsVotedOn.begin(); std::map<uint256, int>::iterator it = mapGovernanceObjectsVotedOn.begin();

View File

@ -200,6 +200,7 @@ void CMasternodeMan::CheckAndRemove()
mWeAskedForMasternodeListEntry.erase((*it).vin.prevout); mWeAskedForMasternodeListEntry.erase((*it).vin.prevout);
// and finally remove it from the list // and finally remove it from the list
it->FlagGovernanceItemsAsDirty();
it = vMasternodes.erase(it); it = vMasternodes.erase(it);
fMasternodesRemoved = true; fMasternodesRemoved = true;
} else { } else {