Skip to content

Commit

Permalink
Bail out in few more places when blockchain is not synced yet (PIVX-P…
Browse files Browse the repository at this point in the history
…roject#2888)

* Bail out in few more places when blockchain is not synced yet

* Apply review suggestion
  • Loading branch information
UdjinM6 authored and panleone committed Nov 10, 2024
1 parent 08f29ba commit d9603ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 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 "quorums_commitment.h"
#include "quorums_dkgsessionmgr.h"
#include "shutdown.h"
#include "tiertwo/tiertwo_sync_state.h"
#include "univalue.h"
#include "validation.h"

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

void CQuorumManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fInitialDownload)
{
if (fInitialDownload || !activeMasternodeManager || !deterministicMNManager->IsDIP3Enforced(pindexNew->nHeight)) {
if (!g_tiertwo_sync_state.IsBlockchainSynced() || !activeMasternodeManager) {
return;
}

Expand Down
16 changes: 13 additions & 3 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "scheduler.h"
#include "spork.h"
#include "sporkid.h"
#include "tiertwo/tiertwo_sync_state.h"
#include "validation.h"

namespace llmq
Expand Down Expand Up @@ -207,15 +208,20 @@ void CChainLocksHandler::TrySignChainTip()
{
Cleanup();

if (!fMasterNode) {
return;
}

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

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

if (!fMasterNode) {
return;
}
if (!pindex->pprev) {
return;
}
Expand Down Expand Up @@ -440,6 +446,10 @@ bool CChainLocksHandler::InternalHasConflictingChainLock(int nHeight, const uint

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

{
LOCK(cs);
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
Expand Down

0 comments on commit d9603ef

Please sign in to comment.