Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually make a difference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fInitialDownload switches to false ~144 blocks deep https://github.com/dashpay/dash/blob/master/src/validation.h#L129 which is ~6 llmq50 quorums. I assume it could be pretty wasteful to scan/ensure connections for these quorums (which are going to be dropped soon after sync is done) but I haven't tested this tbh.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, noticed this wasteful building-up of connections as well 👍

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 @@ -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 @@ -594,6 +600,10 @@ bool CChainLocksHandler::InternalHasConflictingChainLock(int nHeight, const uint

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

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