Browse Source

Nicer logging. Much nicer.

cl-refactor
Gav Wood 10 years ago
parent
commit
616cb14385
  1. 6
      libethereum/State.cpp
  2. 2
      libethereum/State.h
  3. 11
      libp2p/Session.cpp

6
libethereum/State.cpp

@ -467,7 +467,7 @@ bool State::cull(TransactionQueue& _tq) const
return ret;
}
TransactionReceipts State::sync(BlockChain const& _bc, TransactionQueue& _tq, GasPricer const& _gp, bool* o_transactionQueueChanged)
TransactionReceipts State::sync(BlockChain const& _bc, TransactionQueue& _tq, GasPricer const& _gp, bool* o_transactionQueueChanged, unsigned msTimeout)
{
// TRANSACTIONS
TransactionReceipts ret;
@ -475,7 +475,9 @@ TransactionReceipts State::sync(BlockChain const& _bc, TransactionQueue& _tq, Ga
LastHashes lh;
for (int goodTxs = 1; goodTxs;)
auto deadline = chrono::steady_clock::now() + chrono::milliseconds(msTimeout);
for (int goodTxs = 1; goodTxs && chrono::steady_clock::now() < deadline; )
{
goodTxs = 0;
for (auto const& i: ts)

2
libethereum/State.h

@ -205,7 +205,7 @@ public:
/// @returns a list of receipts one for each transaction placed from the queue into the state.
/// @a o_transactionQueueChanged boolean pointer, the value of which will be set to true if the transaction queue
/// changed and the pointer is non-null
TransactionReceipts sync(BlockChain const& _bc, TransactionQueue& _tq, GasPricer const& _gp, bool* o_transactionQueueChanged = nullptr);
TransactionReceipts sync(BlockChain const& _bc, TransactionQueue& _tq, GasPricer const& _gp, bool* o_transactionQueueChanged = nullptr, unsigned _msTimeout = 100);
/// Like sync but only operate on _tq, killing the invalid/old ones.
bool cull(TransactionQueue& _tq) const;

11
libp2p/Session.cpp

@ -48,7 +48,8 @@ Session::Session(Host* _s, RLPXFrameIO* _io, std::shared_ptr<Peer> const& _n, Pe
Session::~Session()
{
clog(NetMessageSummary) << "Closing Peer Session :-(";
ThreadContext tc(info().id.abridged() + " | " + info().clientVersion);
clog(NetMessageSummary) << "Closing peer session :-(";
m_peer->m_lastConnected = m_peer->m_lastAttempted - chrono::seconds(1);
// Read-chain finished for one reason or another.
@ -116,6 +117,8 @@ void Session::ensureNodesRequested()
void Session::serviceNodesRequest()
{
ThreadContext tc(info().id.abridged() + "/" + info().clientVersion);
if (!m_theyRequestedNodes)
return;
@ -320,6 +323,7 @@ void Session::write()
auto self(shared_from_this());
ba::async_write(m_socket, ba::buffer(bytes), [this, self](boost::system::error_code ec, std::size_t /*length*/)
{
ThreadContext tc(info().id.abridged() + " | " + info().clientVersion);
// must check queue, as write callback can occur following dropped()
if (ec)
{
@ -393,7 +397,7 @@ void Session::doRead()
auto self(shared_from_this());
ba::async_read(m_socket, boost::asio::buffer(m_data, h256::size), [this,self](boost::system::error_code ec, std::size_t length)
{
ThreadContext tc(toString(socketId()));
ThreadContext tc(info().id.abridged() + " | " + info().clientVersion);
if (ec && ec.category() != boost::asio::error::get_misc_category() && ec.value() != boost::asio::error::eof)
{
clog(NetWarn) << "Error reading: " << ec.message();
@ -429,8 +433,7 @@ void Session::doRead()
auto tlen = frameSize + ((16 - (frameSize % 16)) % 16) + h128::size;
ba::async_read(m_socket, boost::asio::buffer(m_data, tlen), [this, self, headerRLP, frameSize, tlen](boost::system::error_code ec, std::size_t length)
{
ThreadContext tc1(toString(socketId()));
ThreadContext tc2(toString(info().clientVersion));
ThreadContext tc(info().id.abridged() + " | " + info().clientVersion);
if (ec && ec.category() != boost::asio::error::get_misc_category() && ec.value() != boost::asio::error::eof)
{
clog(NetWarn) << "Error reading: " << ec.message();

Loading…
Cancel
Save