From 62963e91110df441bb577b87270e4fbdb434f214 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 31 May 2017 06:48:47 +0300 Subject: [PATCH] fix sync reset which is triggered erroneously during reindex (#1478) --- src/masternode-sync.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 1ad73e833..c9b36df48 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -49,18 +49,19 @@ bool CMasternodeSync::CheckNodeHeight(CNode* pnode, bool fDisconnectStuckNodes) bool CMasternodeSync::IsBlockchainSynced(bool fBlockAccepted) { static bool fBlockchainSynced = false; - static int64_t nTimeLastProcess = GetTime(); static int nSkipped = 0; static bool fFirstBlockAccepted = false; + if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false; + + static int64_t nTimeLastProcess = GetTime(); + // if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process if(GetTime() - nTimeLastProcess > 60*60) { Reset(); fBlockchainSynced = false; } - if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false; - if(fBlockAccepted) { // this should be only triggered while we are still syncing if(!IsSynced()) {