From 0360be76f21971f21e6e1e3470617c1c95778e77 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 21 Jun 2015 17:11:51 +0200 Subject: [PATCH] Make API room for major syncing. TBI. --- libethereum/Client.cpp | 12 ++++++++++-- libethereum/Client.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 27d967708..f66ef8c3b 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -355,6 +355,14 @@ bool Client::isSyncing() const return false; } +bool Client::isMajorSyncing() const +{ + // TODO: only return true if it is actually doing a proper chain sync. + if (auto h = m_host.lock()) + return h->isSyncing(); + return false; +} + void Client::startedWorking() { // Synchronise the state according to the head of the block chain. @@ -702,7 +710,7 @@ void Client::onChainChanged(ImportRoute const& _ir) // RESTART MINING - if (!isSyncing()) + if (!isMajorSyncing()) { bool preChanged = false; State newPreMine; @@ -765,7 +773,7 @@ void Client::startMining() void Client::rejigMining() { - if ((wouldMine() || remoteActive()) && !isSyncing() && (!isChainBad() || mineOnBadChain()) /*&& (forceMining() || transactionsWaiting())*/) + if ((wouldMine() || remoteActive()) && !isMajorSyncing() && (!isChainBad() || mineOnBadChain()) /*&& (forceMining() || transactionsWaiting())*/) { cnote << "Rejigging mining..."; DEV_WRITE_GUARDED(x_working) diff --git a/libethereum/Client.h b/libethereum/Client.h index c8aad1670..2b168f241 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -219,6 +219,7 @@ public: DownloadMan const* downloadMan() const; bool isSyncing() const; + bool isMajorSyncing() const; /// Sets the network id. void setNetworkId(u256 _n); /// Clears pending transactions. Just for debug use.