3131int nSubmittedFinalBudget;
3232
3333const std::string GovernanceStore::SERIALIZATION_VERSION_STRING = " CGovernanceManager-Version-16" ;
34- const int CGovernanceManager::MAX_TIME_FUTURE_DEVIATION = 60 * 60 ;
35- const int CGovernanceManager::RELIABLE_PROPAGATION_TIME = 60 ;
3634
3735namespace {
36+ constexpr std::chrono::seconds GOVERNANCE_DELETION_DELAY{10min};
37+ constexpr std::chrono::seconds GOVERNANCE_ORPHAN_EXPIRATION_TIME{10min};
38+ constexpr std::chrono::seconds MAX_TIME_FUTURE_DEVIATION{1h};
39+ constexpr std::chrono::seconds RELIABLE_PROPAGATION_TIME{1min};
40+
3841class ScopedLockBool
3942{
4043 bool & ref;
@@ -490,7 +493,7 @@ void CGovernanceManager::CheckAndRemove()
490493 strHash, pObj->GetDeletionTime (), nTimeSinceDeletion, pObj->IsSetCachedDelete (), pObj->IsSetExpired ());
491494
492495 if ((pObj->IsSetCachedDelete () || pObj->IsSetExpired ()) &&
493- (nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) {
496+ (nTimeSinceDeletion >= count_seconds ( GOVERNANCE_DELETION_DELAY) )) {
494497 LogPrint (BCLog::GOBJECT, " CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n " , (*it).first .ToString ());
495498 m_mn_metaman.RemoveGovernanceObject (pObj->GetHash ());
496499
@@ -514,7 +517,7 @@ void CGovernanceManager::CheckAndRemove()
514517 nTimeExpired = std::numeric_limits<int64_t >::max ();
515518 } else {
516519 int64_t nSuperblockCycleSeconds = Params ().GetConsensus ().nSuperblockCycle * Params ().GetConsensus ().nPowTargetSpacing ;
517- nTimeExpired = pObj->GetCreationTime () + 2 * nSuperblockCycleSeconds + GOVERNANCE_DELETION_DELAY;
520+ nTimeExpired = pObj->GetCreationTime () + 2 * nSuperblockCycleSeconds + count_seconds ( GOVERNANCE_DELETION_DELAY) ;
518521 }
519522
520523 mapErasedGovernanceObjects.insert (std::make_pair (nHash, nTimeExpired));
@@ -694,7 +697,7 @@ bool CGovernanceManager::ConfirmInventoryRequest(const CInv& inv)
694697 return false ;
695698 }
696699
697- const auto valid_until = GetTime<std::chrono::seconds>() + std::chrono::seconds ( RELIABLE_PROPAGATION_TIME) ;
700+ const auto valid_until = GetTime<std::chrono::seconds>() + RELIABLE_PROPAGATION_TIME;
698701 const auto & [_itr, inserted] = m_requested_hash_time.emplace (inv.hash , valid_until);
699702
700703 if (inserted) {
@@ -820,7 +823,7 @@ void CGovernanceManager::MasternodeRateUpdate(const CGovernanceObject& govobj)
820823 int64_t nTimestamp = govobj.GetCreationTime ();
821824 it->second .triggerBuffer .AddTimestamp (nTimestamp);
822825
823- if (nTimestamp > GetTime () + MAX_TIME_FUTURE_DEVIATION - RELIABLE_PROPAGATION_TIME) {
826+ if (nTimestamp > GetTime () + count_seconds ( MAX_TIME_FUTURE_DEVIATION) - count_seconds ( RELIABLE_PROPAGATION_TIME) ) {
824827 // schedule additional relay for the object
825828 setAdditionalRelayObjects.insert (govobj.GetHash ());
826829 }
@@ -861,7 +864,7 @@ bool CGovernanceManager::MasternodeRateCheck(const CGovernanceObject& govobj, bo
861864 return false ;
862865 }
863866
864- if (nTimestamp > nNow + MAX_TIME_FUTURE_DEVIATION) {
867+ if (nTimestamp > nNow + count_seconds ( MAX_TIME_FUTURE_DEVIATION) ) {
865868 LogPrint (BCLog::GOBJECT, " CGovernanceManager::MasternodeRateCheck -- object %s rejected due to too new (future) timestamp, masternode = %s, timestamp = %d, current time = %d\n " ,
866869 strHash, masternodeOutpoint.ToStringShort (), nTimestamp, nNow);
867870 return false ;
@@ -935,7 +938,7 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote,
935938 std::string msg{strprintf (" CGovernanceManager::%s -- Unknown parent object %s, MN outpoint = %s" , __func__,
936939 nHashGovobj.ToString (), vote.GetMasternodeOutpoint ().ToStringShort ())};
937940 exception = CGovernanceException (msg, GOVERNANCE_EXCEPTION_WARNING);
938- if (cmmapOrphanVotes.Insert (nHashGovobj, vote_time_pair_t (vote, GetTime<std::chrono::seconds>(). count () + GOVERNANCE_ORPHAN_EXPIRATION_TIME))) {
941+ if (cmmapOrphanVotes.Insert (nHashGovobj, vote_time_pair_t (vote, count_seconds ( GetTime<std::chrono::seconds>() + GOVERNANCE_ORPHAN_EXPIRATION_TIME) ))) {
939942 LEAVE_CRITICAL_SECTION (cs);
940943 RequestGovernanceObject (pfrom, nHashGovobj, connman);
941944 LogPrint (BCLog::GOBJECT, " %s\n " , msg);
@@ -1006,8 +1009,8 @@ void CGovernanceManager::CheckPostponedObjects()
10061009
10071010 int64_t nTimestamp = govobj.GetCreationTime ();
10081011
1009- bool fValid = (nTimestamp <= nNow + MAX_TIME_FUTURE_DEVIATION) && (nTimestamp >= nNow - 2 * nSuperblockCycleSeconds);
1010- bool fReady = (nTimestamp <= nNow + MAX_TIME_FUTURE_DEVIATION - RELIABLE_PROPAGATION_TIME);
1012+ bool fValid = (nTimestamp <= nNow + count_seconds ( MAX_TIME_FUTURE_DEVIATION) ) && (nTimestamp >= nNow - 2 * nSuperblockCycleSeconds);
1013+ bool fReady = (nTimestamp <= nNow + count_seconds ( MAX_TIME_FUTURE_DEVIATION) - count_seconds ( RELIABLE_PROPAGATION_TIME) );
10111014
10121015 if (fValid ) {
10131016 if (fReady ) {
0 commit comments