diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index dfe626570af..3cdce18cadb 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -236,8 +236,13 @@ void BlockChainSync::syncPeer(NodeID const& _peerID, bool _force) return; } - if (m_state == SyncState::Waiting) + if (isSyncPaused()) + { + LOG(m_loggerDetail) << "Can't sync with peer " << _peerID + << " - sync state is paused. Block queue status: " + << host().bq().status(); return; + } u256 td = host().chain().details().totalDifficulty; if (host().bq().isActive()) @@ -284,7 +289,9 @@ void BlockChainSync::requestBlocks(NodeID const& _peerID) clearPeerDownload(_peerID); if (host().bq().knownFull()) { - LOG(m_loggerDetail) << "Waiting for block queue before downloading blocks"; + LOG(m_loggerDetail) + << "Waiting for block queue before downloading blocks. Block queue status: " + << host().bq().status(); pauseSync(); return; } @@ -861,11 +868,6 @@ void BlockChainSync::completeSync() m_state = SyncState::Idle; } -void BlockChainSync::pauseSync() -{ - m_state = SyncState::Waiting; -} - bool BlockChainSync::isSyncing() const { return m_state != SyncState::Idle; diff --git a/libethereum/BlockChainSync.h b/libethereum/BlockChainSync.h index 1295f1932f6..11575a78e8e 100644 --- a/libethereum/BlockChainSync.h +++ b/libethereum/BlockChainSync.h @@ -75,7 +75,8 @@ class BlockChainSync final: public HasInvariants void continueSync(); /// Enter waiting state - void pauseSync(); + void pauseSync() { m_state = SyncState::Waiting; } + bool isSyncPaused() { return m_state == SyncState::Waiting; } EthereumCapability& host() { return m_host; } EthereumCapability const& host() const { return m_host; } diff --git a/libethereum/BlockQueue.cpp b/libethereum/BlockQueue.cpp index 9bb040af58f..b397f75c4bc 100644 --- a/libethereum/BlockQueue.cpp +++ b/libethereum/BlockQueue.cpp @@ -32,10 +32,10 @@ using namespace std; using namespace dev; using namespace dev::eth; -size_t const c_maxKnownCount = 100000; -size_t const c_maxKnownSize = 128 * 1024 * 1024; -size_t const c_maxUnknownCount = 100000; -size_t const c_maxUnknownSize = 512 * 1024 * 1024; // Block size can be ~50kb +constexpr size_t c_maxKnownCount = 100000; +constexpr size_t c_maxKnownSize = 128 * 1024 * 1024; +constexpr size_t c_maxUnknownCount = 100000; +constexpr size_t c_maxUnknownSize = 512 * 1024 * 1024; // Block size can be ~50kb BlockQueue::BlockQueue() { @@ -514,7 +514,8 @@ void BlockQueue::retryAllUnknown() m_moreToVerify.notify_all(); } -std::ostream& dev::eth::operator<<(std::ostream& _out, BlockQueueStatus const& _bqs) +boost::log::formatting_ostream& dev::eth::operator<<( + boost::log::formatting_ostream& _out, BlockQueueStatus const& _bqs) { _out << "importing: " << _bqs.importing << endl; _out << "verified: " << _bqs.verified << endl; diff --git a/libethereum/BlockQueue.h b/libethereum/BlockQueue.h index f20e05c559d..cf11b7f48ee 100644 --- a/libethereum/BlockQueue.h +++ b/libethereum/BlockQueue.h @@ -328,7 +328,7 @@ class BlockQueue: HasInvariants Logger m_loggerDetail{createLogger(VerbosityTrace, "bq")}; }; -std::ostream& operator<<(std::ostream& _out, BlockQueueStatus const& _s); - +boost::log::formatting_ostream& operator<<( + boost::log::formatting_ostream& _out, BlockQueueStatus const& _s); } }