Browse Source

Reorganise logs.

cl-refactor
Gav Wood 10 years ago
parent
commit
091e5d13dd
  1. 26
      libethereum/EthereumHost.cpp
  2. 2
      libethereum/EthereumHost.h

26
libethereum/EthereumHost.cpp

@ -45,6 +45,12 @@ static unsigned const c_maxSendTransactions = 256;
char const* const EthereumHost::s_stateNames[static_cast<int>(SyncState::Size)] = {"Idle", "Waiting", "Hashes", "Blocks", "NewBlocks" }; char const* const EthereumHost::s_stateNames[static_cast<int>(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): EthereumHost::EthereumHost(BlockChain const& _ch, TransactionQueue& _tq, BlockQueue& _bq, u256 _networkId):
HostCapability<EthereumPeer>(), HostCapability<EthereumPeer>(),
Worker ("ethsync"), Worker ("ethsync"),
@ -67,7 +73,7 @@ bool EthereumHost::ensureInitialised()
{ {
// First time - just initialise. // First time - just initialise.
m_latestBlockSent = m_chain.currentHash(); m_latestBlockSent = m_chain.currentHash();
clog(NetNote) << "Initialising: latest=" << m_latestBlockSent; clog(EthereumHostTrace) << "Initialising: latest=" << m_latestBlockSent;
Guard l(x_transactions); Guard l(x_transactions);
m_transactionsSent = m_tq.knownTransactions(); m_transactionsSent = m_tq.knownTransactions();
@ -150,7 +156,7 @@ void EthereumHost::maintainTransactions()
RLPStream ts; RLPStream ts;
_p->prep(ts, TransactionsPacket, n).appendRaw(b, n); _p->prep(ts, TransactionsPacket, n).appendRaw(b, n);
_p->sealAndSend(ts); _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; _p->m_requireTransactions = false;
return true; return true;
@ -206,11 +212,15 @@ void EthereumHost::maintainBlocks(h256 const& _currentHash)
if (diff(detailsFrom.number, detailsTo.number) < 20) 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. // 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)); 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<EthereumPeer> const& p: get<0>(s)) for (shared_ptr<EthereumPeer> const& p: get<0>(s))
for (auto const& b: blocks) for (auto const& b: blocks)
{ {
@ -292,11 +302,11 @@ void EthereumHost::onPeerTransactions(std::shared_ptr<EthereumPeer> _peer, RLP c
{ {
if (_peer->isCriticalSyncing()) if (_peer->isCriticalSyncing())
{ {
clog(NetAllDetail) << "Ignoring transaction from peer we are syncing with"; clog(EthereumHostTrace) << "Ignoring transaction from peer we are syncing with";
return; return;
} }
unsigned itemCount = _r.itemCount(); unsigned itemCount = _r.itemCount();
clog(NetAllDetail) << "Transactions (" << dec << itemCount << "entries)"; clog(EthereumHostTrace) << "Transactions (" << dec << itemCount << "entries)";
m_tq.enqueue(_r, _peer->session()->id()); m_tq.enqueue(_r, _peer->session()->id());
} }
@ -351,10 +361,8 @@ void EthereumHost::onTransactionImported(ImportResult _ir, h256 const& _h, h512
break; break;
case ImportResult::AlreadyKnown: case ImportResult::AlreadyKnown:
// if we already had the transaction, then don't bother sending it on. // if we already had the transaction, then don't bother sending it on.
{ DEV_GUARDED(x_transactions)
Guard l(x_transactions);
m_transactionsSent.insert(_h); m_transactionsSent.insert(_h);
}
peer->addRating(0); peer->addRating(0);
break; break;
case ImportResult::Success: case ImportResult::Success:

2
libethereum/EthereumHost.h

@ -49,6 +49,8 @@ class TransactionQueue;
class BlockQueue; class BlockQueue;
class BlockChainSync; class BlockChainSync;
struct EthereumHostTrace: public LogChannel { static const char* name(); static const int verbosity = 6; };
/** /**
* @brief The EthereumHost class * @brief The EthereumHost class
* @warning None of this is thread-safe. You have been warned. * @warning None of this is thread-safe. You have been warned.

Loading…
Cancel
Save