mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Implemented delay for governance object deletion (#1151)
This commit is contained in:
parent
efa36242a3
commit
90bd7cb62b
@ -211,6 +211,7 @@ void CGovernanceTriggerManager::CleanAndRemove()
|
|||||||
if(pgovobj) {
|
if(pgovobj) {
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring executed object: %s\n", pgovobj->GetHash().ToString());
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring executed object: %s\n", pgovobj->GetHash().ToString());
|
||||||
pgovobj->fExpired = true;
|
pgovobj->fExpired = true;
|
||||||
|
pgovobj->nDeletionTime = GetAdjustedTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove = true;
|
remove = true;
|
||||||
@ -228,6 +229,7 @@ void CGovernanceTriggerManager::CleanAndRemove()
|
|||||||
if(pgovobj) {
|
if(pgovobj) {
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring outdated object: %s\n", pgovobj->GetHash().ToString());
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring outdated object: %s\n", pgovobj->GetHash().ToString());
|
||||||
pgovobj->fExpired = true;
|
pgovobj->fExpired = true;
|
||||||
|
pgovobj->nDeletionTime = GetAdjustedTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,10 @@ void CGovernanceManager::UpdateCachesAndClean()
|
|||||||
|
|
||||||
// IF DELETE=TRUE, THEN CLEAN THE MESS UP!
|
// 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());
|
LogPrintf("CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
|
||||||
mnodeman.RemoveGovernanceObject(pObj->GetHash());
|
mnodeman.RemoveGovernanceObject(pObj->GetHash());
|
||||||
|
|
||||||
@ -783,6 +786,7 @@ CGovernanceObject::CGovernanceObject()
|
|||||||
nHashParent(),
|
nHashParent(),
|
||||||
nRevision(0),
|
nRevision(0),
|
||||||
nTime(0),
|
nTime(0),
|
||||||
|
nDeletionTime(0),
|
||||||
nCollateralHash(),
|
nCollateralHash(),
|
||||||
strData(),
|
strData(),
|
||||||
vinMasternode(),
|
vinMasternode(),
|
||||||
@ -810,6 +814,7 @@ CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, int
|
|||||||
nHashParent(nHashParentIn),
|
nHashParent(nHashParentIn),
|
||||||
nRevision(nRevisionIn),
|
nRevision(nRevisionIn),
|
||||||
nTime(nTimeIn),
|
nTime(nTimeIn),
|
||||||
|
nDeletionTime(0),
|
||||||
nCollateralHash(nCollateralHashIn),
|
nCollateralHash(nCollateralHashIn),
|
||||||
strData(strDataIn),
|
strData(strDataIn),
|
||||||
vinMasternode(),
|
vinMasternode(),
|
||||||
@ -837,6 +842,7 @@ CGovernanceObject::CGovernanceObject(const CGovernanceObject& other)
|
|||||||
nHashParent(other.nHashParent),
|
nHashParent(other.nHashParent),
|
||||||
nRevision(other.nRevision),
|
nRevision(other.nRevision),
|
||||||
nTime(other.nTime),
|
nTime(other.nTime),
|
||||||
|
nDeletionTime(other.nDeletionTime),
|
||||||
nCollateralHash(other.nCollateralHash),
|
nCollateralHash(other.nCollateralHash),
|
||||||
strData(other.strData),
|
strData(other.strData),
|
||||||
vinMasternode(other.vinMasternode),
|
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_FUNDING) >= nAbsVoteReq) fCachedFunding = true;
|
||||||
if(GetAbsoluteYesCount(VOTE_SIGNAL_VALID) >= nAbsVoteReq) fCachedValid = 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;
|
if(GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED) >= nAbsVoteReq) fCachedEndorsed = true;
|
||||||
|
|
||||||
// ARE ANY OF THE VOTING FLAGS NEGATIVELY SET BY THE NETWORK?
|
// 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.nHashParent, second.nHashParent);
|
||||||
swap(first.nRevision, second.nRevision);
|
swap(first.nRevision, second.nRevision);
|
||||||
swap(first.nTime, second.nTime);
|
swap(first.nTime, second.nTime);
|
||||||
|
swap(first.nDeletionTime, second.nDeletionTime);
|
||||||
swap(first.nCollateralHash, second.nCollateralHash);
|
swap(first.nCollateralHash, second.nCollateralHash);
|
||||||
swap(first.strData, second.strData);
|
swap(first.strData, second.strData);
|
||||||
swap(first.nObjectType, second.nObjectType);
|
swap(first.nObjectType, second.nObjectType);
|
||||||
|
@ -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_FEE_CONFIRMATIONS = 6;
|
||||||
static const int64_t GOVERNANCE_UPDATE_MIN = 60*60;
|
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
|
// FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES
|
||||||
static const int SEEN_OBJECT_IS_VALID = 0;
|
static const int SEEN_OBJECT_IS_VALID = 0;
|
||||||
@ -370,6 +372,9 @@ private:
|
|||||||
/// time this object was created
|
/// time this object was created
|
||||||
int64_t nTime;
|
int64_t nTime;
|
||||||
|
|
||||||
|
/// time this object was marked for deletion
|
||||||
|
int64_t nDeletionTime;
|
||||||
|
|
||||||
/// fee-tx
|
/// fee-tx
|
||||||
uint256 nCollateralHash;
|
uint256 nCollateralHash;
|
||||||
|
|
||||||
@ -431,6 +436,10 @@ public:
|
|||||||
return nTime;
|
return nTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t GetDeletionTime() const {
|
||||||
|
return nDeletionTime;
|
||||||
|
}
|
||||||
|
|
||||||
int GetObjectType() const {
|
int GetObjectType() const {
|
||||||
return nObjectType;
|
return nObjectType;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user