Deletion time fix (#1205)
* Fix deletion time bug * Only set deletion time if it has not already been set
This commit is contained in:
parent
072b0fd708
commit
711a5fbf20
@ -668,7 +668,6 @@ void CGovernanceObject::UpdateSentinelVariables()
|
|||||||
|
|
||||||
fCachedFunding = false;
|
fCachedFunding = false;
|
||||||
fCachedValid = true; //default to valid
|
fCachedValid = true; //default to valid
|
||||||
fCachedDelete = false;
|
|
||||||
fCachedEndorsed = false;
|
fCachedEndorsed = false;
|
||||||
fDirtyCache = false;
|
fDirtyCache = false;
|
||||||
|
|
||||||
@ -676,9 +675,11 @@ void CGovernanceObject::UpdateSentinelVariables()
|
|||||||
// ARE ANY OF THESE FLAGS CURRENTLY ACTIVATED?
|
// ARE ANY OF THESE FLAGS CURRENTLY ACTIVATED?
|
||||||
|
|
||||||
if(GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING) >= nAbsVoteReq) fCachedFunding = true;
|
if(GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING) >= nAbsVoteReq) fCachedFunding = true;
|
||||||
if(GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsDeleteReq) {
|
if((GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsDeleteReq) && !fCachedDelete) {
|
||||||
fCachedDelete = true;
|
fCachedDelete = true;
|
||||||
nDeletionTime = GetAdjustedTime();
|
if(nDeletionTime == 0) {
|
||||||
|
nDeletionTime = GetAdjustedTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED) >= nAbsVoteReq) fCachedEndorsed = true;
|
if(GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED) >= nAbsVoteReq) fCachedEndorsed = true;
|
||||||
|
|
||||||
|
@ -312,6 +312,8 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogPrint("gobject", "CGovernanceManager::AddGovernanceObject -- Adding object: hash = %s, type = %d\n", nHash.ToString(), govobj.GetObjectType());
|
||||||
|
|
||||||
// INSERT INTO OUR GOVERNANCE OBJECT MEMORY
|
// INSERT INTO OUR GOVERNANCE OBJECT MEMORY
|
||||||
mapObjects.insert(std::make_pair(nHash, govobj));
|
mapObjects.insert(std::make_pair(nHash, govobj));
|
||||||
|
|
||||||
@ -330,6 +332,7 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
|
|||||||
break;
|
break;
|
||||||
case GOVERNANCE_OBJECT_WATCHDOG:
|
case GOVERNANCE_OBJECT_WATCHDOG:
|
||||||
mapWatchdogObjects[nHash] = GetAdjustedTime() + GOVERNANCE_WATCHDOG_EXPIRATION_TIME;
|
mapWatchdogObjects[nHash] = GetAdjustedTime() + GOVERNANCE_WATCHDOG_EXPIRATION_TIME;
|
||||||
|
LogPrint("gobject", "CGovernanceManager::AddGovernanceObject -- Added watchdog to map: hash = %s\n", nHash.ToString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -350,14 +353,20 @@ void CGovernanceManager::UpdateCachesAndClean()
|
|||||||
|
|
||||||
// Flag expired watchdogs for removal
|
// Flag expired watchdogs for removal
|
||||||
int64_t nNow = GetAdjustedTime();
|
int64_t nNow = GetAdjustedTime();
|
||||||
|
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- Number watchdogs in map: %d, current time = %d\n", mapWatchdogObjects.size(), nNow);
|
||||||
if(mapWatchdogObjects.size() > 1) {
|
if(mapWatchdogObjects.size() > 1) {
|
||||||
hash_time_m_it it = mapWatchdogObjects.begin();
|
hash_time_m_it it = mapWatchdogObjects.begin();
|
||||||
while(it != mapWatchdogObjects.end()) {
|
while(it != mapWatchdogObjects.end()) {
|
||||||
|
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- Checking watchdog: %s, expiration time = %d\n", it->first.ToString(), it->second);
|
||||||
if(it->second < nNow) {
|
if(it->second < nNow) {
|
||||||
|
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- Attempting to expire watchdog: %s, expiration time = %d\n", it->first.ToString(), it->second);
|
||||||
object_m_it it2 = mapObjects.find(it->first);
|
object_m_it it2 = mapObjects.find(it->first);
|
||||||
if(it2 != mapObjects.end()) {
|
if(it2 != mapObjects.end()) {
|
||||||
|
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- Expiring watchdog: %s, expiration time = %d\n", it->first.ToString(), it->second);
|
||||||
it2->second.fExpired = true;
|
it2->second.fExpired = true;
|
||||||
it2->second.nDeletionTime = nNow;
|
if(it2->second.nDeletionTime == 0) {
|
||||||
|
it2->second.nDeletionTime = nNow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mapWatchdogObjects.erase(it++);
|
mapWatchdogObjects.erase(it++);
|
||||||
}
|
}
|
||||||
@ -400,6 +409,8 @@ void CGovernanceManager::UpdateCachesAndClean()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string strHash = pObj->GetHash().ToString();
|
||||||
|
|
||||||
// IF CACHE IS NOT DIRTY, WHY DO THIS?
|
// IF CACHE IS NOT DIRTY, WHY DO THIS?
|
||||||
if(pObj->IsSetDirtyCache()) {
|
if(pObj->IsSetDirtyCache()) {
|
||||||
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
|
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
|
||||||
@ -413,6 +424,9 @@ void CGovernanceManager::UpdateCachesAndClean()
|
|||||||
|
|
||||||
int64_t nTimeSinceDeletion = GetAdjustedTime() - pObj->GetDeletionTime();
|
int64_t nTimeSinceDeletion = GetAdjustedTime() - pObj->GetDeletionTime();
|
||||||
|
|
||||||
|
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- Checking object for deletion: %s, deletion time = %d, time since deletion = %d, delete flag = %d, expired flag = %d\n",
|
||||||
|
strHash, pObj->GetDeletionTime(), nTimeSinceDeletion, pObj->IsSetCachedDelete(), pObj->IsSetExpired());
|
||||||
|
|
||||||
if((pObj->IsSetCachedDelete() || pObj->IsSetExpired()) &&
|
if((pObj->IsSetCachedDelete() || pObj->IsSetExpired()) &&
|
||||||
(nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) {
|
(nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) {
|
||||||
LogPrintf("CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
|
LogPrintf("CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
|
||||||
|
Loading…
Reference in New Issue
Block a user