mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
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 (fLiteMode || !masternodeSync.IsSynced() || ShutdownRequested()) return;
|
||||||
|
|
||||||
if (deterministicMNManager->IsDIP3Enforced()) {
|
|
||||||
RemoveInvalidVotes();
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
||||||
|
|
||||||
CleanOrphanObjects();
|
CleanOrphanObjects();
|
||||||
@ -1330,11 +1326,15 @@ void CGovernanceManager::CleanOrphanObjects()
|
|||||||
|
|
||||||
void CGovernanceManager::RemoveInvalidVotes()
|
void CGovernanceManager::RemoveInvalidVotes()
|
||||||
{
|
{
|
||||||
auto curMNList = deterministicMNManager->GetListAtChainTip();
|
if (!masternodeSync.IsSynced()) {
|
||||||
auto diff = lastMNListForVotingKeys.BuildDiff(curMNList);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
|
auto curMNList = deterministicMNManager->GetListAtChainTip();
|
||||||
|
auto diff = lastMNListForVotingKeys.BuildDiff(curMNList);
|
||||||
|
|
||||||
std::vector<COutPoint> changedKeyMNs;
|
std::vector<COutPoint> changedKeyMNs;
|
||||||
for (const auto& p : diff.updatedMNs) {
|
for (const auto& p : diff.updatedMNs) {
|
||||||
auto oldDmn = lastMNListForVotingKeys.GetMN(p.first);
|
auto oldDmn = lastMNListForVotingKeys.GetMN(p.first);
|
||||||
|
Loading…
Reference in New Issue
Block a user