From 174ee8f88077e2394f570c458ba9680fee95b6e5 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 27 Sep 2016 11:56:10 +0300 Subject: [PATCH] apply IBD-like logic in IsBlockchainSynced --- src/masternode-sync.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 732b11289..cdaa45c6d 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -29,15 +29,14 @@ bool CMasternodeSync::IsBlockchainSynced() lastProcess = GetTime(); if(fBlockchainSynced) return true; + if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false; - if (fImporting || fReindex) return false; + // same as !IsInitialBlockDownload() but no cs_main needed here + int nMaxBlockTime = std::max(pCurrentBlockIndex->GetBlockTime(), pindexBestHeader->GetBlockTime()); + fBlockchainSynced = pindexBestHeader->nHeight - pCurrentBlockIndex->nHeight < 24 * 6 && + GetTime() - nMaxBlockTime < Params().MaxTipAge(); - if(!pCurrentBlockIndex) return false; - if(pCurrentBlockIndex->nTime + 60*60 < GetTime()) return false; - - fBlockchainSynced = true; - - return true; + return fBlockchainSynced; } void CMasternodeSync::Fail()