Skip to content

Commit e6543b9

Browse files
tgflynnUdjinM6
authored andcommitted
Don't add non-current wd's to seen map (dashpay#1417)
1 parent 92eaefb commit e6543b9

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/governance.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,18 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
219219

220220
govobj.UpdateSentinelVariables(); //this sets local vars in object
221221

222-
if(AddGovernanceObject(govobj, pfrom))
222+
bool fAddToSeen = true;
223+
if(AddGovernanceObject(govobj, fAddToSeen, pfrom))
223224
{
224225
LogPrintf("MNGOVERNANCEOBJECT -- %s new\n", strHash);
225226
govobj.Relay();
226227
}
227228

228-
// UPDATE THAT WE'VE SEEN THIS OBJECT
229-
mapSeenGovernanceObjects.insert(std::make_pair(nHash, SEEN_OBJECT_IS_VALID));
229+
if(fAddToSeen) {
230+
// UPDATE THAT WE'VE SEEN THIS OBJECT
231+
mapSeenGovernanceObjects.insert(std::make_pair(nHash, SEEN_OBJECT_IS_VALID));
232+
}
233+
230234
masternodeSync.AddedGovernanceItem();
231235

232236

@@ -305,13 +309,15 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, CGovernance
305309
fRateChecksEnabled = true;
306310
}
307311

308-
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CNode* pfrom)
312+
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, bool& fAddToSeen, CNode* pfrom)
309313
{
310314
LOCK2(cs_main, cs);
311315
std::string strError = "";
312316

313317
DBG( cout << "CGovernanceManager::AddGovernanceObject START" << endl; );
314318

319+
fAddToSeen = true;
320+
315321
uint256 nHash = govobj.GetHash();
316322

317323
// MAKE SURE THIS OBJECT IS OK
@@ -341,6 +347,8 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CNode* p
341347
}
342348

343349
if(!UpdateCurrentWatchdog(govobj)) {
350+
// Allow wd's which are not current to be reprocessed
351+
fAddToSeen = false;
344352
if(pfrom && (nHashWatchdogCurrent != uint256())) {
345353
pfrom->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, nHashWatchdogCurrent));
346354
}
@@ -1007,7 +1015,8 @@ void CGovernanceManager::CheckMasternodeOrphanObjects()
10071015
continue;
10081016
}
10091017

1010-
if(AddGovernanceObject(govobj)) {
1018+
bool fAddToSeen = true;
1019+
if(AddGovernanceObject(govobj, fAddToSeen)) {
10111020
LogPrintf("CGovernanceManager::CheckMasternodeOrphanObjects -- %s new\n", govobj.GetHash().ToString());
10121021
govobj.Relay();
10131022
mapMasternodeOrphanObjects.erase(it++);

src/governance.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class CGovernanceManager
288288
std::vector<CGovernanceObject*> GetAllNewerThan(int64_t nMoreThanTime);
289289

290290
bool IsBudgetPaymentBlock(int nBlockHeight);
291-
bool AddGovernanceObject(CGovernanceObject& govobj, CNode* pfrom = NULL);
291+
bool AddGovernanceObject(CGovernanceObject& govobj, bool& fAddToSeen, CNode* pfrom = NULL);
292292

293293
std::string GetRequiredPaymentsString(int nBlockHeight);
294294

src/rpcgovernance.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ UniValue gobject(const UniValue& params, bool fHelp)
221221
governance.AddSeenGovernanceObject(govobj.GetHash(), SEEN_OBJECT_IS_VALID);
222222
govobj.Relay();
223223
LogPrintf("gobject(submit) -- Adding locally created governance object - %s\n", strHash);
224-
governance.AddGovernanceObject(govobj);
224+
bool fAddToSeen = true;
225+
governance.AddGovernanceObject(govobj, fAddToSeen);
225226

226227
return govobj.GetHash().ToString();
227228
}

0 commit comments

Comments
 (0)