Merge #878: governance propagation
98b7d29 fix invalid cached govobj values 581b46a added information explaining cached variable meanings 390c9c3 add dirty flag for future use b76304e added other cached flags into output
This commit is contained in:
parent
de64f11347
commit
b43381c2c6
@ -133,6 +133,9 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
||||
else if (strCommand == NetMsgType::MNGOVERNANCEOBJECT)
|
||||
|
||||
{
|
||||
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
|
||||
|
||||
if(!pCurrentBlockIndex) return;
|
||||
|
||||
CGovernanceObject govobj;
|
||||
vRecv >> govobj;
|
||||
@ -158,10 +161,10 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
||||
return;
|
||||
}
|
||||
|
||||
if(AddGovernanceObject(govobj))
|
||||
{
|
||||
govobj.Relay();
|
||||
}
|
||||
// UPDATE CACHED VARIABLES FOR THIS OBJECT AND ADD IT TO OUR MANANGED DATA
|
||||
|
||||
govobj.UpdateSentinelVariables(pCurrentBlockIndex);
|
||||
if(AddGovernanceObject(govobj)) govobj.Relay();
|
||||
|
||||
mapSeenGovernanceObjects.insert(make_pair(govobj.GetHash(), SEEN_OBJECT_IS_VALID));
|
||||
masternodeSync.AddedBudgetItem(govobj.GetHash());
|
||||
@ -254,6 +257,10 @@ void CGovernanceManager::CheckAndRemove()
|
||||
{
|
||||
LogPrintf("CGovernanceManager::CheckAndRemove \n");
|
||||
|
||||
// DOUBLE CHECK THAT WE HAVE A VALID POINTER TO TIP
|
||||
|
||||
if(!pCurrentBlockIndex) return;
|
||||
|
||||
// DELETE OBJECTS WHICH MASTERNODE HAS FLAGGED DELETE=TRUE
|
||||
|
||||
std::map<uint256, CGovernanceObject>::iterator it = mapObjects.begin();
|
||||
@ -261,29 +268,21 @@ void CGovernanceManager::CheckAndRemove()
|
||||
{
|
||||
CGovernanceObject* pObj = &((*it).second);
|
||||
|
||||
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
|
||||
pObj->UpdateLocalValidity(pCurrentBlockIndex);
|
||||
// UPDATE SENTINEL SIGNALING VARIABLES
|
||||
pObj->UpdateSentinelVariables(pCurrentBlockIndex);
|
||||
|
||||
// SHOULD WE DELETE THIS OBJECT FROM MEMORY
|
||||
|
||||
/*
|
||||
- delete objects from memory where fCachedDelete is true
|
||||
- this should be robust enough that if someone sends us the proposal later, we should know it was deleted
|
||||
*/
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
// UPDATE CACHING MECHANISMS FOR GOVERNANCE OBJECTS
|
||||
|
||||
if(!pCurrentBlockIndex) return;
|
||||
|
||||
std::string strError = "";
|
||||
|
||||
std::map<uint256, CGovernanceObject>::iterator it2 = mapObjects.begin();
|
||||
while(it2 != mapObjects.end())
|
||||
{
|
||||
CGovernanceObject* pObj = &((*it2).second);
|
||||
|
||||
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
|
||||
pObj->UpdateLocalValidity(pCurrentBlockIndex);
|
||||
|
||||
// UPDATE SENTINEL SIGNALING VARIABLES
|
||||
pObj->UpdateSentinelVariables(pCurrentBlockIndex);
|
||||
++it2;
|
||||
}
|
||||
}
|
||||
|
||||
CGovernanceObject *CGovernanceManager::FindGovernanceObject(const std::string &strName)
|
||||
@ -536,6 +535,12 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, std::strin
|
||||
|
||||
mapVotesByType[nTypeHash] = vote;
|
||||
mapVotesByHash[nHash] = vote;
|
||||
|
||||
// // SET CACHE AS DIRTY / WILL BE UPDATED NEXT BLOCK
|
||||
|
||||
// CGovernanceObject* pGovObj = FindGovernanceObject(vote.GetParentHash());
|
||||
// if(pGovObj) pGovObj->fDirtyCache = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -553,7 +558,7 @@ CGovernanceObject::CGovernanceObject()
|
||||
fCachedValid = true;
|
||||
fCachedDelete = false;
|
||||
fCachedEndorsed = false;
|
||||
|
||||
//fDirtyCache = true;
|
||||
}
|
||||
|
||||
CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTimeIn, uint256 nFeeTXHashIn)
|
||||
@ -563,6 +568,13 @@ CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std
|
||||
strName = strNameIn;
|
||||
nTime = nTimeIn;
|
||||
nFeeTXHash = nFeeTXHashIn; //fee-tx
|
||||
|
||||
// caching
|
||||
fCachedFunding = false;
|
||||
fCachedValid = true;
|
||||
fCachedDelete = false;
|
||||
fCachedEndorsed = false;
|
||||
//fDirtyCache = true;
|
||||
}
|
||||
|
||||
CGovernanceObject::CGovernanceObject(const CGovernanceObject& other)
|
||||
@ -575,6 +587,13 @@ CGovernanceObject::CGovernanceObject(const CGovernanceObject& other)
|
||||
nTime = other.nTime;
|
||||
nFeeTXHash = other.nFeeTXHash;
|
||||
strData = other.strData;
|
||||
|
||||
// caching
|
||||
fCachedFunding = other.fCachedFunding;
|
||||
fCachedValid = other.fCachedValid;
|
||||
fCachedDelete = other.fCachedDelete;
|
||||
fCachedEndorsed = other.fCachedEndorsed;
|
||||
//fDirtyCache = other.fDirtyCache;
|
||||
}
|
||||
|
||||
bool CGovernanceObject::IsValid(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral)
|
||||
|
@ -176,11 +176,12 @@ public:
|
||||
std::string strLocalValidityError;
|
||||
|
||||
// set via sentinel voting mechanisms
|
||||
// caching -- one per voting mechanism -- see governance-vote.h for more information
|
||||
bool fCachedFunding;
|
||||
bool fCachedValid;
|
||||
bool fCachedDelete;
|
||||
bool fCachedEndorsed;
|
||||
// caching -- one per voting mechanism -- see below for more information
|
||||
bool fCachedFunding; // true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though)
|
||||
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)
|
||||
bool fCachedDelete; // true == minimum network support has been reached saying this object should be deleted from the system entirely
|
||||
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)
|
||||
// bool fDirtyCache; // object was updated and cached values should be updated soon
|
||||
|
||||
CGovernanceObject();
|
||||
CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTime, uint256 nFeeTXHashIn);
|
||||
@ -257,7 +258,6 @@ public:
|
||||
void CleanAndRemove(bool fSignatureCheck);
|
||||
void Relay();
|
||||
|
||||
|
||||
uint256 GetHash(){
|
||||
|
||||
// CREATE HASH OF ALL IMPORTANT PIECES OF DATA
|
||||
@ -310,6 +310,8 @@ public:
|
||||
READWRITE(nTime);
|
||||
READWRITE(nFeeTXHash);
|
||||
READWRITE(strData);
|
||||
|
||||
// AFTER DESERIALIZATION OCCURS, CACHED VARIABLES MUST BE CALCULATED MANUALLY
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -324,6 +324,9 @@ UniValue mngovernance(const UniValue& params, bool fHelp)
|
||||
bObj.push_back(Pair("IsValid", pbudgetProposal->IsValid(pindex, strError)));
|
||||
bObj.push_back(Pair("IsValidReason", strError.c_str()));
|
||||
bObj.push_back(Pair("fCachedValid", pbudgetProposal->fCachedValid));
|
||||
bObj.push_back(Pair("fCachedFunding", pbudgetProposal->fCachedFunding));
|
||||
bObj.push_back(Pair("fCachedDelete", pbudgetProposal->fCachedDelete));
|
||||
bObj.push_back(Pair("fCachedEndorsed", pbudgetProposal->fCachedEndorsed));
|
||||
|
||||
resultObj.push_back(Pair(pbudgetProposal->GetName(), bObj));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user