diff --git a/src/governance-object.cpp b/src/governance-object.cpp index 67ef9a769..4d05a1f2b 100644 --- a/src/governance-object.cpp +++ b/src/governance-object.cpp @@ -795,6 +795,7 @@ std::vector CGovernanceObject::RemoveOldVotes(unsigned int nMinTime) { LOCK(cs); + // Drop pre-DIP3 votes from vote db auto removed = fileVotes.RemoveOldVotes(nMinTime); if (!removed.empty()) { @@ -806,5 +807,24 @@ std::vector CGovernanceObject::RemoveOldVotes(unsigned int nMinTime) fDirtyCache = true; } + // Same for current votes per MN for this specific object + auto itMnPair = mapCurrentMNVotes.begin(); + while (itMnPair != mapCurrentMNVotes.end()) { + auto& miRef = itMnPair->second.mapInstances; + auto itVotePair = miRef.begin(); + while (itVotePair != miRef.end()) { + if (itVotePair->second.nTime < nMinTime) { + miRef.erase(itVotePair++); + } else { + ++itVotePair; + } + } + if (miRef.empty()) { + mapCurrentMNVotes.erase(itMnPair++); + } else { + ++itMnPair; + } + } + return removed; }