From 4b7bd6be8f5b69a5ad6dbc3014a5c9d0fecbe720 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Wed, 18 Jan 2017 10:24:19 -0500 Subject: [PATCH] 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 --- src/governance-object.cpp | 1 + src/masternode.cpp | 14 -------------- src/masternodeman.cpp | 1 + 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/governance-object.cpp b/src/governance-object.cpp index c14eaa79b..0f8d7e940 100644 --- a/src/governance-object.cpp +++ b/src/governance-object.cpp @@ -170,6 +170,7 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom, } voteInstance = vote_instance_t(vote.GetOutcome(), nVoteTimeUpdate); fileVotes.AddVote(vote); + mnodeman.AddGovernanceVote(vote.GetVinMasternode(), vote.GetParentHash()); fDirtyCache = true; return true; } diff --git a/src/masternode.cpp b/src/masternode.cpp index ba408c627..7b4363f7f 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -219,8 +219,6 @@ void CMasternode::Check(bool fForce) nActiveState = MASTERNODE_UPDATE_REQUIRED; if(nActiveStatePrev != nActiveState) { LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); - // RESCAN AFFECTED VOTES - FlagGovernanceItemsAsDirty(); } return; } @@ -259,8 +257,6 @@ void CMasternode::Check(bool fForce) nActiveState = MASTERNODE_NEW_START_REQUIRED; if(nActiveStatePrev != nActiveState) { LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); - // RESCAN AFFECTED VOTES - FlagGovernanceItemsAsDirty(); } return; } @@ -283,8 +279,6 @@ void CMasternode::Check(bool fForce) nActiveState = MASTERNODE_EXPIRED; if(nActiveStatePrev != nActiveState) { LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString()); - // RESCAN AFFECTED VOTES - FlagGovernanceItemsAsDirty(); } return; } @@ -962,14 +956,6 @@ void CMasternode::UpdateWatchdogVoteTime() */ void CMasternode::FlagGovernanceItemsAsDirty() { - std::map::iterator it = mapGovernanceObjectsVotedOn.begin(); - while(it != mapGovernanceObjectsVotedOn.end()){ - CGovernanceObject *pObj = governance.FindGovernanceObject((*it).first); - - if(pObj) pObj->InvalidateVoteCache(); - ++it; - } - std::vector vecDirty; { std::map::iterator it = mapGovernanceObjectsVotedOn.begin(); diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index ac11375f4..a65ee7bc0 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -200,6 +200,7 @@ void CMasternodeMan::CheckAndRemove() mWeAskedForMasternodeListEntry.erase((*it).vin.prevout); // and finally remove it from the list + it->FlagGovernanceItemsAsDirty(); it = vMasternodes.erase(it); fMasternodesRemoved = true; } else {