diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index d92a3835f..32f346601 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -610,7 +610,6 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import } clog(BlockChainNote) << " Imported and best" << td << " (#" << bi.number << "). Has" << (details(bi.parentHash).children.size() - 1) << "siblings. Route:" << route; - noteCanonChanged(); StructuredLogger::chainNewHead( bi.headerHash(WithoutNonce).abridged(), @@ -643,6 +642,9 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import cnote << "checkBest:" << checkBest; #endif + if (route.size()) + noteCanonChanged(); + if (isKnown(bi.hash()) && !details(bi.hash())) { clog(BlockChainDebug) << "Known block just inserted has no details."; diff --git a/libethereum/CommonNet.h b/libethereum/CommonNet.h index 2083e9919..0b1469f19 100644 --- a/libethereum/CommonNet.h +++ b/libethereum/CommonNet.h @@ -56,7 +56,7 @@ class EthereumPeer; enum { StatusPacket = 0, - GetTransactionsPacket, + NewBlockHashesPacket, TransactionsPacket, GetBlockHashesPacket, BlockHashesPacket, diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 249831540..a3327bbf8 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -326,7 +326,6 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) transition(Asking::Nothing); break; } - case GetTransactionsPacket: break; // DEPRECATED. case TransactionsPacket: { unsigned itemCount = _r.itemCount(); @@ -565,6 +564,49 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) } break; } +/* case NewBlockHashesPacket: + { + clog(NetMessageSummary) << "NewBlock: " << h; + if (_r.itemCount() == 1) + disable("NewBlock without any data fields."); + else if (host()->isSyncing()) + clog(NetMessageSummary) << "Ignoring since we're already downloading."; + else + { + unsigned knowns = 0; + unsigned unknowns = 0; + for (unsigned i = 0; i < itemCount; ++i) + { + addRating(1); + auto h = _r[i].toHash(); + 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 << "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; + transition(Asking::Blocks); + return true; + } + break; + }*/ default: return false; }