Various fixes for RemoveInvalidVotes() (#2845)
* Fix crash in RemoveInvalidVotes() Caused by lock not being held while accessing lastMNListForVotingKeys when RemoveInvalidVotes() is called from DoMaintenance() and UpdatedBlockTip() at the same time. * No need to call RemoveInvalidVotes() from DoMaintenance() MN list only changes on new blocks and we already call RemoveInvalidVotes() from UpdatedBlockTip() * No need to call RemoveInvalidVotes() until we are fully synced
This commit is contained in:
parent
b5bc7c9dac
commit
1ba8694cd7
@ -557,10 +557,6 @@ void CGovernanceManager::DoMaintenance(CConnman& connman)
|
||||
{
|
||||
if (fLiteMode || !masternodeSync.IsSynced() || ShutdownRequested()) return;
|
||||
|
||||
if (deterministicMNManager->IsDIP3Enforced()) {
|
||||
RemoveInvalidVotes();
|
||||
}
|
||||
|
||||
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
||||
|
||||
CleanOrphanObjects();
|
||||
@ -1330,11 +1326,15 @@ void CGovernanceManager::CleanOrphanObjects()
|
||||
|
||||
void CGovernanceManager::RemoveInvalidVotes()
|
||||
{
|
||||
auto curMNList = deterministicMNManager->GetListAtChainTip();
|
||||
auto diff = lastMNListForVotingKeys.BuildDiff(curMNList);
|
||||
if (!masternodeSync.IsSynced()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK(cs);
|
||||
|
||||
auto curMNList = deterministicMNManager->GetListAtChainTip();
|
||||
auto diff = lastMNListForVotingKeys.BuildDiff(curMNList);
|
||||
|
||||
std::vector<COutPoint> changedKeyMNs;
|
||||
for (const auto& p : diff.updatedMNs) {
|
||||
auto oldDmn = lastMNListForVotingKeys.GetMN(p.first);
|
||||
|
Loading…
Reference in New Issue
Block a user