Skip to content

Commit

Permalink
only consider higher hashes if they don't exceed nExpirationDelay (#1361
Browse files Browse the repository at this point in the history
)
  • Loading branch information
UdjinM6 committed Feb 23, 2017
1 parent 0bc6d92 commit a1ef547
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ bool CGovernanceManager::UpdateCurrentWatchdog(CGovernanceObject& watchdogNew)
int64_t nExpirationDelay = GOVERNANCE_WATCHDOG_EXPIRATION_TIME / 2;
int64_t nNow = GetTime();

if((nHashWatchdogCurrent == uint256()) ||
(((nNow - nTimeWatchdogCurrent) > nExpirationDelay) && (nNow - watchdogNew.GetCreationTime() < nExpirationDelay)) ||
(nHashNew > nHashCurrent)) {
if(nHashWatchdogCurrent == uint256() || // no known current OR
((nNow - watchdogNew.GetCreationTime() < nExpirationDelay) && // (new one is NOT expired AND
((nNow - nTimeWatchdogCurrent > nExpirationDelay) || (nHashNew > nHashCurrent)))// (current is expired OR
// its hash is lower))
) {
LOCK(cs);
object_m_it it = mapObjects.find(nHashWatchdogCurrent);
if(it != mapObjects.end()) {
Expand Down

0 comments on commit a1ef547

Please sign in to comment.