Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Log block queue status in BlockChainSync (#5595)
Browse files Browse the repository at this point in the history
Log block queue status in BlockChainSync
  • Loading branch information
gumb0 authored May 9, 2019
2 parents 4e63cf2 + b25d30d commit 32f9c88
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
16 changes: 9 additions & 7 deletions libethereum/BlockChainSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion libethereum/BlockChainSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
11 changes: 6 additions & 5 deletions libethereum/BlockQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libethereum/BlockQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 32f9c88

Please sign in to comment.