Drop pre-DIP3 votes from current votes per MN per object (#2524)
This commit is contained in:
parent
7037f7c999
commit
08dc178711
@ -795,6 +795,7 @@ std::vector<uint256> 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<uint256> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user