@@ -33,7 +33,6 @@ CGovernanceManager::CGovernanceManager() :
3333 nCachedBlockHeight(0 ),
3434 mapObjects(),
3535 mapErasedGovernanceObjects(),
36- mapMasternodeOrphanObjects(),
3736 cmapVoteToObject(MAX_CACHE_SIZE),
3837 cmapInvalidVotes(MAX_CACHE_SIZE),
3938 cmmapOrphanVotes(MAX_CACHE_SIZE),
@@ -161,8 +160,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
161160
162161 LOCK2 (cs_main, cs);
163162
164- if (mapObjects.count (nHash) || mapPostponedObjects.count (nHash) ||
165- mapErasedGovernanceObjects.count (nHash) || mapMasternodeOrphanObjects.count (nHash)) {
163+ if (mapObjects.count (nHash) || mapPostponedObjects.count (nHash) || mapErasedGovernanceObjects.count (nHash)) {
166164 // TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
167165 LogPrint (BCLog::GOBJECT, " MNGOVERNANCEOBJECT -- Received already seen object: %s\n " , strHash);
168166 return ;
@@ -177,33 +175,18 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
177175 std::string strError = " " ;
178176 // CHECK OBJECT AGAINST LOCAL BLOCKCHAIN
179177
180- bool fMasternodeMissing = false ;
181178 bool fMissingConfirmations = false ;
182- bool fIsValid = govobj.IsValidLocally (strError, fMasternodeMissing , fMissingConfirmations , true );
179+ bool fIsValid = govobj.IsValidLocally (strError, fMissingConfirmations , true );
183180
184- if (fRateCheckBypassed && ( fIsValid || fMasternodeMissing ) ) {
181+ if (fRateCheckBypassed && fIsValid ) {
185182 if (!MasternodeRateCheck (govobj, true )) {
186183 LogPrintf (" MNGOVERNANCEOBJECT -- masternode rate check failed (after signature verification) - %s - (current block height %d)\n " , strHash, nCachedBlockHeight);
187184 return ;
188185 }
189186 }
190187
191188 if (!fIsValid ) {
192- if (fMasternodeMissing ) {
193- int & count = mapMasternodeOrphanCounter[govobj.GetMasternodeOutpoint ()];
194- if (count >= 10 ) {
195- LogPrint (BCLog::GOBJECT, " MNGOVERNANCEOBJECT -- Too many orphan objects, missing masternode=%s\n " , govobj.GetMasternodeOutpoint ().ToStringShort ());
196- // ask for this object again in 2 minutes
197- CInv inv (MSG_GOVERNANCE_OBJECT, govobj.GetHash ());
198- pfrom->AskFor (inv);
199- return ;
200- }
201-
202- count++;
203- ExpirationInfo info (pfrom->GetId (), GetAdjustedTime () + GOVERNANCE_ORPHAN_EXPIRATION_TIME);
204- mapMasternodeOrphanObjects.insert (std::make_pair (nHash, object_info_pair_t (govobj, info)));
205- LogPrintf (" MNGOVERNANCEOBJECT -- Missing masternode for: %s, strError = %s\n " , strHash, strError);
206- } else if (fMissingConfirmations ) {
189+ if (fMissingConfirmations ) {
207190 AddPostponedObject (govobj);
208191 LogPrintf (" MNGOVERNANCEOBJECT -- Not enough fee confirmations for: %s, strError = %s\n " , strHash, strError);
209192 } else {
@@ -863,52 +846,6 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote,
863846 return fOk ;
864847}
865848
866- void CGovernanceManager::CheckMasternodeOrphanVotes (CConnman& connman)
867- {
868- LOCK2 (cs_main, cs);
869-
870- ScopedLockBool guard (cs, fRateChecksEnabled , false );
871-
872- for (auto & objPair : mapObjects) {
873- objPair.second .CheckOrphanVotes (connman);
874- }
875- }
876-
877- void CGovernanceManager::CheckMasternodeOrphanObjects (CConnman& connman)
878- {
879- LOCK2 (cs_main, cs);
880- int64_t nNow = GetAdjustedTime ();
881- ScopedLockBool guard (cs, fRateChecksEnabled , false );
882- object_info_m_it it = mapMasternodeOrphanObjects.begin ();
883- while (it != mapMasternodeOrphanObjects.end ()) {
884- object_info_pair_t & pair = it->second ;
885- CGovernanceObject& govobj = pair.first ;
886-
887- if (pair.second .nExpirationTime >= nNow) {
888- std::string strError;
889- bool fMasternodeMissing = false ;
890- bool fConfirmationsMissing = false ;
891- bool fIsValid = govobj.IsValidLocally (strError, fMasternodeMissing , fConfirmationsMissing , true );
892-
893- if (fIsValid ) {
894- AddGovernanceObject (govobj, connman);
895- } else if (fMasternodeMissing ) {
896- ++it;
897- continue ;
898- }
899- } else {
900- // apply node's ban score
901- Misbehaving (pair.second .idFrom , 20 );
902- }
903-
904- auto it_count = mapMasternodeOrphanCounter.find (govobj.GetMasternodeOutpoint ());
905- if (--it_count->second == 0 )
906- mapMasternodeOrphanCounter.erase (it_count);
907-
908- mapMasternodeOrphanObjects.erase (it++);
909- }
910- }
911-
912849void CGovernanceManager::CheckPostponedObjects (CConnman& connman)
913850{
914851 if (!masternodeSync.IsSynced ()) return ;
0 commit comments