From ac488d70b96c9de9f8ff615468d99aeb1180702a Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 13 Aug 2015 16:07:38 +0300 Subject: [PATCH] stop mining before completely synced, more info in rpc --- src/miner.cpp | 3 ++- src/rpcmining.cpp | 8 ++++++-- src/rpcmisc.cpp | 1 + src/rpcprotocol.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7c9accbd1..8fa80a16a 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 a856ce692..3283e86ce 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 5aa41de1f..96178c23b 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 95244d79a..119800c56 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