@@ -320,7 +320,7 @@ MessageProcessingResult CGovernanceManager::ProcessMessage(CNode& peer, CConnman
320320            return  ret;
321321        }
322322
323-         AddGovernanceObject (govobj, &peer);
323+         InternalAddGovernanceObject (govobj, &peer);
324324        return  ret;
325325    }
326326
@@ -398,9 +398,12 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj)
398398    }
399399}
400400
401- void  CGovernanceManager::AddGovernanceObject  (CGovernanceObject& govobj, const  CNode* pfrom)
401+ void  CGovernanceManager::InternalAddGovernanceObject  (CGovernanceObject& govobj, const  CNode* pfrom)
402402{
403+     AssertLockHeld (::cs_main);
404+     AssertLockHeld (cs_store);
403405    AssertLockNotHeld (cs_relay);
406+ 
404407    uint256 nHash = govobj.GetHash ();
405408    std::string strHash = nHash.ToString ();
406409
@@ -410,7 +413,6 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, const CN
410413
411414    govobj.UpdateSentinelVariables (tip_mn_list); // this sets local vars in object
412415
413-     LOCK2 (::cs_main, cs_store);
414416    std::string strError;
415417
416418    //  MAKE SURE THIS OBJECT IS OK
@@ -459,6 +461,15 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, const CN
459461    GetMainSignals ().NotifyGovernanceObject (std::make_shared<const  Governance::Object>(govobj.Object ()), nHash.ToString ());
460462}
461463
464+ void  CGovernanceManager::AddGovernanceObject (CGovernanceObject& govobj, const  CNode* pfrom)
465+ {
466+     AssertLockNotHeld (cs_store);
467+     AssertLockNotHeld (cs_relay);
468+ 
469+     LOCK2 (::cs_main, cs_store);
470+     InternalAddGovernanceObject (govobj, pfrom);
471+ }
472+ 
462473void  CGovernanceManager::CheckAndRemove ()
463474{
464475    AssertLockNotHeld (cs_store);
@@ -989,12 +1000,11 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote,
9891000
9901001void  CGovernanceManager::CheckPostponedObjects ()
9911002{
1003+     AssertLockHeld (::cs_main);
9921004    AssertLockHeld (cs_store);
9931005    AssertLockNotHeld (cs_relay);
9941006    if  (!m_mn_sync.IsSynced ()) return ;
9951007
996-     LOCK (::cs_main);
997- 
9981008    //  Check postponed proposals
9991009    for  (auto  it = mapPostponedObjects.begin (); it != mapPostponedObjects.end ();) {
10001010        const  uint256& nHash = it->first ;
@@ -1006,7 +1016,7 @@ void CGovernanceManager::CheckPostponedObjects()
10061016        bool  fMissingConfirmations ;
10071017        if  (govobj.IsCollateralValid (m_chainman, strError, fMissingConfirmations )) {
10081018            if  (govobj.IsValidLocally (Assert (m_dmnman)->GetListAtChainTip (), m_chainman, strError, false )) {
1009-                 AddGovernanceObject (govobj);
1019+                 InternalAddGovernanceObject (govobj);
10101020            } else  {
10111021                LogPrint (BCLog::GOBJECT, " CGovernanceManager::CheckPostponedObjects -- %s invalid\n " ToString ());
10121022            }
@@ -1379,7 +1389,7 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex)
13791389    nCachedBlockHeight = pindex->nHeight ;
13801390    LogPrint (BCLog::GOBJECT, " CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: %d\n " 
13811391
1382-     LOCK ( cs_store);
1392+     LOCK2 (::cs_main,  cs_store);
13831393    if  (DeploymentDIP0003Enforced (pindex->nHeight , Params ().GetConsensus ())) {
13841394        RemoveInvalidVotes ();
13851395    }
0 commit comments