Skip to content

Commit

Permalink
Bail out in few more places when blockchain is not synced yet
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Apr 26, 2019
1 parent 2652030 commit 6c268be
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "activemasternode.h"
#include "chainparams.h"
#include "init.h"
#include "masternode-sync.h"
#include "univalue.h"
#include "validation.h"

Expand Down Expand Up @@ -161,7 +162,7 @@ CQuorumManager::CQuorumManager(CEvoDB& _evoDb, CBLSWorker& _blsWorker, CDKGSessi

void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
{
if (fInitialDownload) {
if (!masternodeSync.IsBlockchainSynced()) {
return;
}

Expand Down
20 changes: 17 additions & 3 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "quorums_utils.h"

#include "chain.h"
#include "masternode-sync.h"
#include "net_processing.h"
#include "scheduler.h"
#include "spork.h"
Expand Down Expand Up @@ -232,15 +233,20 @@ void CChainLocksHandler::TrySignChainTip()
{
Cleanup();

if (!fMasternodeMode) {
return;
}

if (!masternodeSync.IsBlockchainSynced()) {
return;
}

const CBlockIndex* pindex;
{
LOCK(cs_main);
pindex = chainActive.Tip();
}

if (!fMasternodeMode) {
return;
}
if (!pindex->pprev) {
return;
}
Expand Down Expand Up @@ -407,6 +413,10 @@ bool CChainLocksHandler::IsTxSafeForMining(const uint256& txid)
// This should also not be called from validation signals, as this might result in recursive calls
void CChainLocksHandler::EnforceBestChainLock()
{
if (!masternodeSync.IsBlockchainSynced()) {
return;
}

CChainLockSig clsig;
const CBlockIndex* pindex;
const CBlockIndex* currentBestChainLockBlockIndex;
Expand Down Expand Up @@ -594,6 +604,10 @@ bool CChainLocksHandler::InternalHasConflictingChainLock(int nHeight, const uint

void CChainLocksHandler::Cleanup()
{
if (!masternodeSync.IsBlockchainSynced()) {
return;
}

{
LOCK(cs);
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
Expand Down
11 changes: 6 additions & 5 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "governance.h"
#include "instantx.h"
#include "keepass.h"
#include "masternode-sync.h"
#include "privatesend-client.h"
#include "spork.h"

Expand Down Expand Up @@ -2310,7 +2311,7 @@ CAmount CWallet::GetBalance() const

CAmount CWallet::GetAnonymizableBalance(bool fSkipDenominated, bool fSkipUnconfirmed) const
{
if(fLiteMode) return 0;
if (fLiteMode || !masternodeSync.IsBlockchainSynced()) return 0;

std::vector<CompactTallyItem> vecTally;
if(!SelectCoinsGroupedByAddresses(vecTally, fSkipDenominated, true, fSkipUnconfirmed)) return 0;
Expand All @@ -2332,7 +2333,7 @@ CAmount CWallet::GetAnonymizableBalance(bool fSkipDenominated, bool fSkipUnconfi

CAmount CWallet::GetAnonymizedBalance() const
{
if(fLiteMode) return 0;
if (fLiteMode || !masternodeSync.IsBlockchainSynced()) return 0;

CAmount nTotal = 0;

Expand All @@ -2356,7 +2357,7 @@ CAmount CWallet::GetAnonymizedBalance() const
// that's ok as long as we use it for informational purposes only
float CWallet::GetAverageAnonymizedRounds() const
{
if(fLiteMode) return 0;
if (fLiteMode || !masternodeSync.IsBlockchainSynced()) return 0;

int nTotal = 0;
int nCount = 0;
Expand All @@ -2378,7 +2379,7 @@ float CWallet::GetAverageAnonymizedRounds() const
// that's ok as long as we use it for informational purposes only
CAmount CWallet::GetNormalizedAnonymizedBalance() const
{
if(fLiteMode) return 0;
if (fLiteMode || !masternodeSync.IsBlockchainSynced()) return 0;

CAmount nTotal = 0;

Expand Down Expand Up @@ -2424,7 +2425,7 @@ CAmount CWallet::GetNeedsToBeAnonymizedBalance(CAmount nMinBalance) const

CAmount CWallet::GetDenominatedBalance(bool unconfirmed) const
{
if(fLiteMode) return 0;
if (fLiteMode || !masternodeSync.IsBlockchainSynced()) return 0;

CAmount nTotal = 0;

Expand Down

0 comments on commit 6c268be

Please sign in to comment.