diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 4d50a12ae..d730771a0 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -121,7 +121,7 @@ void EthereumPeer::transition(Asking _a, bool _force) clog(NetWarn) << "Bad state: asking for Hashes yet not syncing!"; setAsking(_a, true); - prep(s, GetBlockHashesPacket, 2) << m_syncingNeededBlocks.back() << c_maxHashesAsk; + prep(s, GetBlockHashesPacket, 2) << m_syncingLastReceivedHash << c_maxHashesAsk; sealAndSend(s); return; } @@ -385,6 +385,8 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) transition(Asking::Blocks); return true; } + unsigned knowns = 0; + unsigned unknowns = 0; for (unsigned i = 0; i < _r.itemCount(); ++i) { addRating(1); @@ -392,18 +394,26 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) auto status = host()->m_bq.blockStatus(h); if (status == QueueStatus::Importing || status == QueueStatus::Ready || host()->m_chain.isKnown(h)) { + clog(NetMessageSummary) << "block hash ready:" << h << ". Start blocks download..."; transition(Asking::Blocks); return true; } else if (status == QueueStatus::Bad) { - cwarn << "BAD hash chain discovered. Ignoring."; + cwarn << "block hash bad!" << h << ". Bailing..."; transition(Asking::Nothing); return true; } else if (status == QueueStatus::Unknown) + { + unknowns++; m_syncingNeededBlocks.push_back(h); + } + else + knowns++; + m_syncingLastReceivedHash = h; } + clog(NetMessageSummary) << knowns << "knowns," << unknowns << "unknowns; now at" << m_syncingLastReceivedHash.abridged(); // run through - ask for more. transition(Asking::Hashes); break; diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index da144134b..a80d5dadd 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -129,6 +129,7 @@ private: /// This is built as we ask for hashes. Once no more hashes are given, we present this to the /// host who initialises the DownloadMan and m_sub becomes active for us to begin asking for blocks. h256s m_syncingNeededBlocks; ///< The blocks that we should download from this peer. + h256 m_syncingLastReceivedHash; ///< Hash more recently received from peer. h256 m_syncingLatestHash; ///< Peer's latest block's hash, as of the current sync. u256 m_syncingTotalDifficulty; ///< Peer's latest block's total difficulty, as of the current sync.