From 3280097495bfa84e3a0b3b48acb1ee0ccd0e5634 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 1 Dec 2017 08:14:57 +0300 Subject: [PATCH] fine-tune sync conditions in getblocktemplate (#1739) --- src/rpc/mining.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index ab7ea2398..353d4404c 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -27,6 +27,9 @@ #include "utilstrencodings.h" #include "validationinterface.h" +#include "masternode-payments.h" +#include "governance-classes.h" + #include #include @@ -498,8 +501,18 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dash Core is downloading blocks..."); - if (!masternodeSync.IsSynced()) - throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dash Core is syncing with network..."); + // when enforcement is on we need information about a masternode payee or otherwise our block is going to be orphaned by the network + CScript payee; + if (sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) + && !masternodeSync.IsWinnersListSynced() + && !mnpayments.GetBlockPayee(chainActive.Height() + 1, payee)) + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dash Core is downloading masternode winners..."); + + // next bock is a superblock and we need governance info to correctly construct it + if (sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED) + && !masternodeSync.IsSynced() + && CSuperblock::IsValidBlockHeight(chainActive.Height() + 1)) + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dash Core is syncing with network..."); static unsigned int nTransactionsUpdatedLast;