@@ -321,7 +321,7 @@ MessageProcessingResult CGovernanceManager::ProcessMessage(CNode& peer, CConnman
321321 return ret;
322322 }
323323
324- AddGovernanceObject (govobj, &peer);
324+ InternalAddGovernanceObject (govobj, &peer);
325325 return ret;
326326 }
327327
@@ -399,9 +399,12 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj)
399399 }
400400}
401401
402- void CGovernanceManager::AddGovernanceObject (CGovernanceObject& govobj, const CNode* pfrom)
402+ void CGovernanceManager::InternalAddGovernanceObject (CGovernanceObject& govobj, const CNode* pfrom)
403403{
404+ AssertLockHeld (::cs_main);
405+ AssertLockHeld (cs_store);
404406 AssertLockNotHeld (cs_relay);
407+
405408 uint256 nHash = govobj.GetHash ();
406409 std::string strHash = nHash.ToString ();
407410
@@ -411,7 +414,6 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, const CN
411414
412415 govobj.UpdateSentinelVariables (tip_mn_list); // this sets local vars in object
413416
414- LOCK2 (::cs_main, cs_store);
415417 std::string strError;
416418
417419 // MAKE SURE THIS OBJECT IS OK
@@ -460,6 +462,15 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, const CN
460462 GetMainSignals ().NotifyGovernanceObject (std::make_shared<const Governance::Object>(govobj.Object ()), nHash.ToString ());
461463}
462464
465+ void CGovernanceManager::AddGovernanceObject (CGovernanceObject& govobj, const CNode* pfrom)
466+ {
467+ AssertLockNotHeld (cs_store);
468+ AssertLockNotHeld (cs_relay);
469+
470+ LOCK2 (::cs_main, cs_store);
471+ InternalAddGovernanceObject (govobj, pfrom);
472+ }
473+
463474void CGovernanceManager::CheckAndRemove ()
464475{
465476 AssertLockNotHeld (cs_store);
@@ -991,12 +1002,11 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote,
9911002
9921003void CGovernanceManager::CheckPostponedObjects ()
9931004{
1005+ AssertLockHeld (::cs_main);
9941006 AssertLockHeld (cs_store);
9951007 AssertLockNotHeld (cs_relay);
9961008 if (!m_mn_sync.IsSynced ()) return ;
9971009
998- LOCK (::cs_main);
999-
10001010 // Check postponed proposals
10011011 for (auto it = mapPostponedObjects.begin (); it != mapPostponedObjects.end ();) {
10021012 const uint256& nHash = it->first ;
@@ -1008,7 +1018,7 @@ void CGovernanceManager::CheckPostponedObjects()
10081018 bool fMissingConfirmations ;
10091019 if (govobj.IsCollateralValid (m_chainman, strError, fMissingConfirmations )) {
10101020 if (govobj.IsValidLocally (Assert (m_dmnman)->GetListAtChainTip (), m_chainman, strError, false )) {
1011- AddGovernanceObject (govobj);
1021+ InternalAddGovernanceObject (govobj);
10121022 } else {
10131023 LogPrint (BCLog::GOBJECT, " CGovernanceManager::CheckPostponedObjects -- %s invalid\n " , nHash.ToString ());
10141024 }
@@ -1381,7 +1391,7 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex)
13811391 nCachedBlockHeight = pindex->nHeight ;
13821392 LogPrint (BCLog::GOBJECT, " CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: %d\n " , nCachedBlockHeight);
13831393
1384- LOCK ( cs_store);
1394+ LOCK2 (::cs_main, cs_store);
13851395 if (DeploymentDIP0003Enforced (pindex->nHeight , Params ().GetConsensus ())) {
13861396 RemoveInvalidVotes ();
13871397 }
0 commit comments