diff --git a/src/governance-classes.cpp b/src/governance-classes.cpp index 098b398c2..7094925c7 100644 --- a/src/governance-classes.cpp +++ b/src/governance-classes.cpp @@ -211,6 +211,7 @@ void CGovernanceTriggerManager::CleanAndRemove() if(pgovobj) { LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring executed object: %s\n", pgovobj->GetHash().ToString()); pgovobj->fExpired = true; + pgovobj->nDeletionTime = GetAdjustedTime(); } } remove = true; @@ -228,6 +229,7 @@ void CGovernanceTriggerManager::CleanAndRemove() if(pgovobj) { LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring outdated object: %s\n", pgovobj->GetHash().ToString()); pgovobj->fExpired = true; + pgovobj->nDeletionTime = GetAdjustedTime(); } } } diff --git a/src/governance.cpp b/src/governance.cpp index db7f159f1..191a025b7 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -366,7 +366,10 @@ void CGovernanceManager::UpdateCachesAndClean() // IF DELETE=TRUE, THEN CLEAN THE MESS UP! - if(pObj->IsSetCachedDelete() || pObj->IsSetExpired()) { + int64_t nTimeSinceDeletion = GetAdjustedTime() - pObj->GetDeletionTime(); + + if((pObj->IsSetCachedDelete() || pObj->IsSetExpired()) && + (nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) { LogPrintf("CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString()); mnodeman.RemoveGovernanceObject(pObj->GetHash()); @@ -783,6 +786,7 @@ CGovernanceObject::CGovernanceObject() nHashParent(), nRevision(0), nTime(0), + nDeletionTime(0), nCollateralHash(), strData(), vinMasternode(), @@ -810,6 +814,7 @@ CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, int nHashParent(nHashParentIn), nRevision(nRevisionIn), nTime(nTimeIn), + nDeletionTime(0), nCollateralHash(nCollateralHashIn), strData(strDataIn), vinMasternode(), @@ -837,6 +842,7 @@ CGovernanceObject::CGovernanceObject(const CGovernanceObject& other) nHashParent(other.nHashParent), nRevision(other.nRevision), nTime(other.nTime), + nDeletionTime(other.nDeletionTime), nCollateralHash(other.nCollateralHash), strData(other.strData), vinMasternode(other.vinMasternode), @@ -1454,7 +1460,10 @@ void CGovernanceObject::UpdateSentinelVariables(const CBlockIndex *pCurrentBlock if(GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING) >= nAbsVoteReq) fCachedFunding = true; if(GetAbsoluteYesCount(VOTE_SIGNAL_VALID) >= nAbsVoteReq) fCachedValid = true; - if(GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsVoteReq) fCachedDelete = true; + if(GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsVoteReq) { + fCachedDelete = true; + nDeletionTime = GetAdjustedTime(); + } if(GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED) >= nAbsVoteReq) fCachedEndorsed = true; // ARE ANY OF THE VOTING FLAGS NEGATIVELY SET BY THE NETWORK? @@ -1476,6 +1485,7 @@ void CGovernanceObject::swap(CGovernanceObject& first, CGovernanceObject& second swap(first.nHashParent, second.nHashParent); swap(first.nRevision, second.nRevision); swap(first.nTime, second.nTime); + swap(first.nDeletionTime, second.nDeletionTime); swap(first.nCollateralHash, second.nCollateralHash); swap(first.strData, second.strData); swap(first.nObjectType, second.nObjectType); diff --git a/src/governance.h b/src/governance.h index 7dab00f44..38a75b899 100644 --- a/src/governance.h +++ b/src/governance.h @@ -46,6 +46,8 @@ static const CAmount GOVERNANCE_PROPOSAL_FEE_TX = (0.33*COIN); static const int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6; static const int64_t GOVERNANCE_UPDATE_MIN = 60*60; +static const int64_t GOVERNANCE_DELETION_DELAY = 10*60; + // FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES static const int SEEN_OBJECT_IS_VALID = 0; @@ -370,6 +372,9 @@ private: /// time this object was created int64_t nTime; + /// time this object was marked for deletion + int64_t nDeletionTime; + /// fee-tx uint256 nCollateralHash; @@ -431,6 +436,10 @@ public: return nTime; } + int64_t GetDeletionTime() const { + return nDeletionTime; + } + int GetObjectType() const { return nObjectType; }