From 8126e924419776716e28cc69764648cddcf69296 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Sat, 3 Dec 2016 14:46:08 -0500 Subject: [PATCH] Merge #1185: Trigger removel changes - Do not expire superblock triggers on execution - Expire trigger objects about 1 day (576 blocks) after their event height is past --- src/governance-classes.cpp | 18 +++--------------- src/governance-object.h | 1 + 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/governance-classes.cpp b/src/governance-classes.cpp index 7094925c78..510676cfb7 100644 --- a/src/governance-classes.cpp +++ b/src/governance-classes.cpp @@ -204,24 +204,13 @@ void CGovernanceTriggerManager::CleanAndRemove() LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Unknown or invalid trigger found\n"); remove = true; break; - case SEEN_OBJECT_EXECUTED: - { - LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Executed trigger found\n"); - CGovernanceObject* pgovobj = pSuperblock->GetGovernanceObject(); - if(pgovobj) { - LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Expiring executed object: %s\n", pgovobj->GetHash().ToString()); - pgovobj->fExpired = true; - pgovobj->nDeletionTime = GetAdjustedTime(); - } - } - remove = true; - break; case SEEN_OBJECT_IS_VALID: + case SEEN_OBJECT_EXECUTED: { int nTriggerBlock = pSuperblock->GetBlockStart(); // Rough approximation: a cycle of superblock ++ - int nExpirationBlock = nTriggerBlock + Params().GetConsensus().nSuperblockCycle + GOVERNANCE_FEE_CONFIRMATIONS; - LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- nTriggerBlock = %d, nExpriartionBlock = %d\n"); + int nExpirationBlock = nTriggerBlock + GOVERNANCE_TRIGGER_EXPIRATION_BLOCKS; + LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- nTriggerBlock = %d, nExpirationBlock = %d\n", nTriggerBlock, nExpirationBlock); if(governance.GetCachedBlockHeight() > nExpirationBlock) { LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Outdated trigger found\n"); remove = true; @@ -459,7 +448,6 @@ void CSuperblockManager::CreateSuperblock(CMutableTransaction& txNewRet, int nBl DBG( cout << "CSuperblockManager::CreateSuperblock Before LogPrintf call, nAmount = " << payment.nAmount << endl; ); LogPrintf("NEW Superblock : output %d (addr %s, amount %d)\n", i, address2.ToString(), payment.nAmount); DBG( cout << "CSuperblockManager::CreateSuperblock After LogPrintf call " << endl; ); - pSuperblock->SetExecuted(); } else { DBG( cout << "CSuperblockManager::CreateSuperblock Payment not found " << endl; ); } diff --git a/src/governance-object.h b/src/governance-object.h index 05994a8fbc..e08c82fc89 100644 --- a/src/governance-object.h +++ b/src/governance-object.h @@ -50,6 +50,7 @@ static const int64_t GOVERNANCE_DELETION_DELAY = 10*60; static const int64_t GOVERNANCE_ORPHAN_EXPIRATION_TIME = 10*60; static const int64_t GOVERNANCE_WATCHDOG_EXPIRATION_TIME = 2*60*60; +static const int GOVERNANCE_TRIGGER_EXPIRATION_BLOCKS = 576; // FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES static const int SEEN_OBJECT_IS_VALID = 0;