diff --git a/libethereum/EthereumHost.cpp b/libethereum/EthereumHost.cpp index 186eb6fa8..f00ec7dc7 100644 --- a/libethereum/EthereumHost.cpp +++ b/libethereum/EthereumHost.cpp @@ -45,6 +45,12 @@ static unsigned const c_maxSendTransactions = 256; char const* const EthereumHost::s_stateNames[static_cast(SyncState::Size)] = {"Idle", "Waiting", "Hashes", "Blocks", "NewBlocks" }; +#ifdef _WIN32 +const char* EthereumHostTrace::name() { return EthPurple "^" EthGray " "; } +#else +const char* EthereumHostTrace::name() { return EthPurple "⧫" EthGray " "; } +#endif + EthereumHost::EthereumHost(BlockChain const& _ch, TransactionQueue& _tq, BlockQueue& _bq, u256 _networkId): HostCapability(), Worker ("ethsync"), @@ -67,7 +73,7 @@ bool EthereumHost::ensureInitialised() { // First time - just initialise. m_latestBlockSent = m_chain.currentHash(); - clog(NetNote) << "Initialising: latest=" << m_latestBlockSent; + clog(EthereumHostTrace) << "Initialising: latest=" << m_latestBlockSent; Guard l(x_transactions); m_transactionsSent = m_tq.knownTransactions(); @@ -150,7 +156,7 @@ void EthereumHost::maintainTransactions() RLPStream ts; _p->prep(ts, TransactionsPacket, n).appendRaw(b, n); _p->sealAndSend(ts); - cnote << "Sent" << n << "transactions to " << _p->session()->info().clientVersion; + clog(EthereumHostTrace) << "Sent" << n << "transactions to " << _p->session()->info().clientVersion; } _p->m_requireTransactions = false; return true; @@ -206,11 +212,15 @@ void EthereumHost::maintainBlocks(h256 const& _currentHash) if (diff(detailsFrom.number, detailsTo.number) < 20) { // don't be sending more than 20 "new" blocks. if there are any more we were probably waaaay behind. - clog(NetMessageSummary) << "Sending a new block (current is" << _currentHash << ", was" << m_latestBlockSent << ")"; + clog(EthereumHostTrace) << "Sending a new block (current is" << _currentHash << ", was" << m_latestBlockSent << ")"; h256s blocks = get<0>(m_chain.treeRoute(m_latestBlockSent, _currentHash, false, false, true)); - auto s = randomSelection(25, [&](EthereumPeer* p){ DEV_GUARDED(p->x_knownBlocks) return !p->m_knownBlocks.count(_currentHash); return false; }); + auto s = randomSelection(25, [&](EthereumPeer* p){ + DEV_GUARDED(p->x_knownBlocks) + return !p->m_knownBlocks.count(_currentHash); + return false; + }); for (shared_ptr const& p: get<0>(s)) for (auto const& b: blocks) { @@ -292,11 +302,11 @@ void EthereumHost::onPeerTransactions(std::shared_ptr _peer, RLP c { if (_peer->isCriticalSyncing()) { - clog(NetAllDetail) << "Ignoring transaction from peer we are syncing with"; + clog(EthereumHostTrace) << "Ignoring transaction from peer we are syncing with"; return; } unsigned itemCount = _r.itemCount(); - clog(NetAllDetail) << "Transactions (" << dec << itemCount << "entries)"; + clog(EthereumHostTrace) << "Transactions (" << dec << itemCount << "entries)"; m_tq.enqueue(_r, _peer->session()->id()); } @@ -351,10 +361,8 @@ void EthereumHost::onTransactionImported(ImportResult _ir, h256 const& _h, h512 break; case ImportResult::AlreadyKnown: // if we already had the transaction, then don't bother sending it on. - { - Guard l(x_transactions); + DEV_GUARDED(x_transactions) m_transactionsSent.insert(_h); - } peer->addRating(0); break; case ImportResult::Success: diff --git a/libethereum/EthereumHost.h b/libethereum/EthereumHost.h index b65ddb5d0..6cb82ebb4 100644 --- a/libethereum/EthereumHost.h +++ b/libethereum/EthereumHost.h @@ -49,6 +49,8 @@ class TransactionQueue; class BlockQueue; class BlockChainSync; +struct EthereumHostTrace: public LogChannel { static const char* name(); static const int verbosity = 6; }; + /** * @brief The EthereumHost class * @warning None of this is thread-safe. You have been warned.