diff --git a/src/miner.cpp b/src/miner.cpp index 7c9accbd19..8fa80a16ae 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -20,6 +20,7 @@ #include "wallet.h" #endif #include "masternode-payments.h" +#include "masternode-sync.h" #include #include @@ -474,7 +475,7 @@ void static BitcoinMiner(CWallet *pwallet) LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!fvNodesEmpty && !IsInitialBlockDownload()) + if (!fvNodesEmpty && masternodeSync.IsSynced()) break; MilliSleep(1000); } while (true); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index a856ce6923..3283e86ced 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -19,6 +19,7 @@ #ifdef ENABLE_WALLET #include "db.h" #include "wallet.h" +#include "masternode-sync.h" #endif #include @@ -442,8 +443,11 @@ Value getblocktemplate(const Array& params, bool fHelp) if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Dash is not connected!"); - if (IsInitialBlockDownload()) - throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dash is downloading blocks..."); + if (!masternodeSync.IsBlockchainSynced()) + throw JSONRPCError(RPC_CLIENT_IN_BLOCKCHAIN_SYNC, "Dash is trying to sync blocks..."); + + if (!masternodeSync.IsSynced()) + throw JSONRPCError(RPC_CLIENT_IN_ADDITIONAL_SYNC, "Dash is trying to sync additional data... Use 'mnsync status' to get more info."); static unsigned int nTransactionsUpdatedLast; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5aa41de1f3..96178c23be 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -123,6 +123,7 @@ Value mnsync(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("IsBlockchainSynced", masternodeSync.IsBlockchainSynced())); + obj.push_back(Pair("IsSynced", masternodeSync.IsSynced())); obj.push_back(Pair("lastMasternodeList", masternodeSync.lastMasternodeList)); obj.push_back(Pair("lastMasternodeWinner", masternodeSync.lastMasternodeWinner)); obj.push_back(Pair("lastBudgetItem", masternodeSync.lastBudgetItem)); diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 95244d79af..119800c560 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -63,6 +63,8 @@ enum RPCErrorCode //! P2P client errors RPC_CLIENT_NOT_CONNECTED = -9, //! Dash is not connected RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, //! Still downloading initial blocks + RPC_CLIENT_IN_BLOCKCHAIN_SYNC = -110,//! Syncing blocks + RPC_CLIENT_IN_ADDITIONAL_SYNC = -111,//! Syncing additional data RPC_CLIENT_NODE_ALREADY_ADDED = -23, //! Node is already added RPC_CLIENT_NODE_NOT_ADDED = -24, //! Node has not been added before