Browse Source

offset logic for eth packets

cl-refactor
subtly 10 years ago
parent
commit
339e4aec33
  1. 16
      libethereum/EthereumPeer.cpp

16
libethereum/EthereumPeer.cpp

@ -324,8 +324,8 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
case GetTransactionsPacket: break; // DEPRECATED. case GetTransactionsPacket: break; // DEPRECATED.
case TransactionsPacket: case TransactionsPacket:
{ {
clogS(NetMessageSummary) << "Transactions (" << dec << (_r.itemCount() - 1) << "entries)"; clogS(NetMessageSummary) << "Transactions (" << dec << _r.itemCount() << "entries)";
addRating(_r.itemCount() - 1); addRating(_r.itemCount());
Guard l(x_knownTransactions); Guard l(x_knownTransactions);
for (unsigned i = 0; i < _r.itemCount(); ++i) for (unsigned i = 0; i < _r.itemCount(); ++i)
{ {
@ -355,14 +355,14 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
} }
case BlockHashesPacket: case BlockHashesPacket:
{ {
clogS(NetMessageSummary) << "BlockHashes (" << dec << (_r.itemCount() - 1) << "entries)" << (_r.itemCount() - 1 ? "" : ": NoMoreHashes"); clogS(NetMessageSummary) << "BlockHashes (" << dec << _r.itemCount() << "entries)" << (_r.itemCount() ? "" : ": NoMoreHashes");
if (m_asking != Asking::Hashes) if (m_asking != Asking::Hashes)
{ {
cwarn << "Peer giving us hashes when we didn't ask for them."; cwarn << "Peer giving us hashes when we didn't ask for them.";
break; break;
} }
if (_r.itemCount() == 1) if (_r.itemCount() == 0)
{ {
transition(Asking::Blocks); transition(Asking::Blocks);
return true; return true;
@ -384,7 +384,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
} }
case GetBlocksPacket: case GetBlocksPacket:
{ {
clogS(NetMessageSummary) << "GetBlocks (" << dec << (_r.itemCount() - 1) << "entries)"; clogS(NetMessageSummary) << "GetBlocks (" << dec << _r.itemCount() << "entries)";
// return the requested blocks. // return the requested blocks.
bytes rlp; bytes rlp;
unsigned n = 0; unsigned n = 0;
@ -404,12 +404,12 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
} }
case BlocksPacket: case BlocksPacket:
{ {
clogS(NetMessageSummary) << "Blocks (" << dec << (_r.itemCount() - 1) << "entries)" << (_r.itemCount() - 1 ? "" : ": NoMoreBlocks"); clogS(NetMessageSummary) << "Blocks (" << dec << _r.itemCount() << "entries)" << (_r.itemCount() ? "" : ": NoMoreBlocks");
if (m_asking != Asking::Blocks) if (m_asking != Asking::Blocks)
clogS(NetWarn) << "Unexpected Blocks received!"; clogS(NetWarn) << "Unexpected Blocks received!";
if (_r.itemCount() == 1) if (_r.itemCount() == 0)
{ {
// Got to this peer's latest block - just give up. // Got to this peer's latest block - just give up.
transition(Asking::Nothing); transition(Asking::Nothing);
@ -470,7 +470,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
auto h = BlockInfo::headerHash(_r[0].data()); auto h = BlockInfo::headerHash(_r[0].data());
clogS(NetMessageSummary) << "NewBlock: " << h.abridged(); clogS(NetMessageSummary) << "NewBlock: " << h.abridged();
if (_r.itemCount() != 3) if (_r.itemCount() != 2)
disable("NewBlock without 2 data fields."); disable("NewBlock without 2 data fields.");
else else
{ {

Loading…
Cancel
Save