Browse Source

Minor fix for mining.

cl-refactor
Gav Wood 10 years ago
parent
commit
7aa4da008b
  1. 4
      libethereum/BlockChain.cpp
  2. 2
      libethereum/CommonNet.h
  3. 44
      libethereum/EthereumPeer.cpp

4
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; clog(BlockChainNote) << " Imported and best" << td << " (#" << bi.number << "). Has" << (details(bi.parentHash).children.size() - 1) << "siblings. Route:" << route;
noteCanonChanged();
StructuredLogger::chainNewHead( StructuredLogger::chainNewHead(
bi.headerHash(WithoutNonce).abridged(), bi.headerHash(WithoutNonce).abridged(),
@ -643,6 +642,9 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import
cnote << "checkBest:" << checkBest; cnote << "checkBest:" << checkBest;
#endif #endif
if (route.size())
noteCanonChanged();
if (isKnown(bi.hash()) && !details(bi.hash())) if (isKnown(bi.hash()) && !details(bi.hash()))
{ {
clog(BlockChainDebug) << "Known block just inserted has no details."; clog(BlockChainDebug) << "Known block just inserted has no details.";

2
libethereum/CommonNet.h

@ -56,7 +56,7 @@ class EthereumPeer;
enum enum
{ {
StatusPacket = 0, StatusPacket = 0,
GetTransactionsPacket, NewBlockHashesPacket,
TransactionsPacket, TransactionsPacket,
GetBlockHashesPacket, GetBlockHashesPacket,
BlockHashesPacket, BlockHashesPacket,

44
libethereum/EthereumPeer.cpp

@ -326,7 +326,6 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
transition(Asking::Nothing); transition(Asking::Nothing);
break; break;
} }
case GetTransactionsPacket: break; // DEPRECATED.
case TransactionsPacket: case TransactionsPacket:
{ {
unsigned itemCount = _r.itemCount(); unsigned itemCount = _r.itemCount();
@ -565,6 +564,49 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
} }
break; 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<h256>();
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: default:
return false; return false;
} }

Loading…
Cancel
Save