Skip to content

Commit 390c9c3

Browse files
author
Evan Duffield
committed
add dirty flag for future use
1 parent 581b46a commit 390c9c3

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/governance.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,30 +265,24 @@ void CGovernanceManager::CheckAndRemove()
265265

266266
std::map<uint256, CGovernanceObject>::iterator it = mapObjects.begin();
267267
while(it != mapObjects.end())
268-
{
268+
{
269269
CGovernanceObject* pObj = &((*it).second);
270270

271+
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
271272
pObj->UpdateLocalValidity(pCurrentBlockIndex);
273+
// UPDATE SENTINEL SIGNALING VARIABLES
272274
pObj->UpdateSentinelVariables(pCurrentBlockIndex);
273-
++it;
274-
}
275275

276-
// UPDATE CACHING MECHANISMS FOR GOVERNANCE OBJECTS
276+
// SHOULD WE DELETE THIS OBJECT FROM MEMORY
277277

278-
std::string strError = "";
278+
/*
279+
- delete objects from memory where fCachedDelete is true
280+
- this should be robust enough that if someone sends us the proposal later, we should know it was deleted
281+
*/
279282

280-
std::map<uint256, CGovernanceObject>::iterator it2 = mapObjects.begin();
281-
while(it2 != mapObjects.end())
282-
{
283-
CGovernanceObject* pObj = &((*it2).second);
284-
285-
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
286-
pObj->UpdateLocalValidity(pCurrentBlockIndex);
287-
288-
// UPDATE SENTINEL SIGNALING VARIABLES
289-
pObj->UpdateSentinelVariables(pCurrentBlockIndex);
290-
++it2;
283+
++it;
291284
}
285+
292286
}
293287

294288
CGovernanceObject *CGovernanceManager::FindGovernanceObject(const std::string &strName)
@@ -541,6 +535,12 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, std::strin
541535

542536
mapVotesByType[nTypeHash] = vote;
543537
mapVotesByHash[nHash] = vote;
538+
539+
// // SET CACHE AS DIRTY / WILL BE UPDATED NEXT BLOCK
540+
541+
// CGovernanceObject* pGovObj = FindGovernanceObject(vote.GetParentHash());
542+
// if(pGovObj) pGovObj->fDirtyCache = true;
543+
544544
return true;
545545
}
546546

@@ -558,7 +558,7 @@ CGovernanceObject::CGovernanceObject()
558558
fCachedValid = true;
559559
fCachedDelete = false;
560560
fCachedEndorsed = false;
561-
561+
//fDirtyCache = true;
562562
}
563563

564564
CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTimeIn, uint256 nFeeTXHashIn)
@@ -574,6 +574,7 @@ CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std
574574
fCachedValid = true;
575575
fCachedDelete = false;
576576
fCachedEndorsed = false;
577+
//fDirtyCache = true;
577578
}
578579

579580
CGovernanceObject::CGovernanceObject(const CGovernanceObject& other)
@@ -592,6 +593,7 @@ CGovernanceObject::CGovernanceObject(const CGovernanceObject& other)
592593
fCachedValid = other.fCachedValid;
593594
fCachedDelete = other.fCachedDelete;
594595
fCachedEndorsed = other.fCachedEndorsed;
596+
//fDirtyCache = other.fDirtyCache;
595597
}
596598

597599
bool CGovernanceObject::IsValid(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral)

src/governance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class CGovernanceObject
181181
bool fCachedValid; // true == minimum network has been reached flagging this object as a valid and understood goverance object (e.g, the serialized data is correct format, etc)
182182
bool fCachedDelete; // true == minimum network support has been reached saying this object should be deleted from the system entirely
183183
bool fCachedEndorsed; // true == minimum network support has been reached flagging this object as endorsed by an elected representative body (e.g. business review board / technecial review board /etc)
184+
// bool fDirtyCache; // object was updated and cached values should be updated soon
184185

185186
CGovernanceObject();
186187
CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTime, uint256 nFeeTXHashIn);
@@ -257,7 +258,6 @@ class CGovernanceObject
257258
void CleanAndRemove(bool fSignatureCheck);
258259
void Relay();
259260

260-
261261
uint256 GetHash(){
262262

263263
// CREATE HASH OF ALL IMPORTANT PIECES OF DATA

0 commit comments

Comments
 (0)