|
@ -425,44 +425,46 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) |
|
|
unsigned future = 0; |
|
|
unsigned future = 0; |
|
|
unsigned unknown = 0; |
|
|
unsigned unknown = 0; |
|
|
unsigned got = 0; |
|
|
unsigned got = 0; |
|
|
|
|
|
unsigned repeated = 0; |
|
|
|
|
|
|
|
|
for (unsigned i = 1; i < _r.itemCount(); ++i) |
|
|
for (unsigned i = 1; i < _r.itemCount(); ++i) |
|
|
{ |
|
|
{ |
|
|
auto h = BlockInfo::headerHash(_r[i].data()); |
|
|
auto h = BlockInfo::headerHash(_r[i].data()); |
|
|
m_sub.noteBlock(h); |
|
|
if (m_sub.noteBlock(h)) |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
Guard l(x_knownBlocks); |
|
|
addRating(10); |
|
|
m_knownBlocks.insert(h); |
|
|
switch (host()->m_bq.import(_r[i].data(), host()->m_chain)) |
|
|
|
|
|
{ |
|
|
|
|
|
case ImportResult::Success: |
|
|
|
|
|
success++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::Malformed: |
|
|
|
|
|
disable("Malformed block received."); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::FutureTime: |
|
|
|
|
|
future++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::AlreadyInChain: |
|
|
|
|
|
case ImportResult::AlreadyKnown: |
|
|
|
|
|
got++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::UnknownParent: |
|
|
|
|
|
unknown++; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
switch (host()->m_bq.import(_r[i].data(), host()->m_chain)) |
|
|
|
|
|
{ |
|
|
{ |
|
|
case ImportResult::Success: |
|
|
addRating(0); // -1?
|
|
|
addRating(1); |
|
|
repeated++; |
|
|
success++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::Malformed: |
|
|
|
|
|
disable("Malformed block received."); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::FutureTime: |
|
|
|
|
|
future++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::AlreadyInChain: |
|
|
|
|
|
case ImportResult::AlreadyKnown: |
|
|
|
|
|
got++; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ImportResult::UnknownParent: |
|
|
|
|
|
unknown++; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
clogS(NetMessageSummary) << dec << success << "imported OK," << unknown << "with unknown parents," << future << "with future timestamps," << got << " already known."; |
|
|
clogS(NetMessageSummary) << dec << success << "imported OK," << unknown << "with unknown parents," << future << "with future timestamps," << got << " already known," << repeated << " repeats received."; |
|
|
|
|
|
|
|
|
if (m_asking == Asking::Blocks) |
|
|
if (m_asking == Asking::Blocks) |
|
|
transition(Asking::Blocks); |
|
|
transition(Asking::Blocks); |
|
@ -480,8 +482,10 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) |
|
|
switch (host()->m_bq.import(_r[1].data(), host()->m_chain)) |
|
|
switch (host()->m_bq.import(_r[1].data(), host()->m_chain)) |
|
|
{ |
|
|
{ |
|
|
case ImportResult::Success: |
|
|
case ImportResult::Success: |
|
|
|
|
|
addRating(100); |
|
|
|
|
|
break; |
|
|
case ImportResult::FutureTime: |
|
|
case ImportResult::FutureTime: |
|
|
addRating(1); |
|
|
//TODO: Rating dependent on how far in future it is.
|
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case ImportResult::Malformed: |
|
|
case ImportResult::Malformed: |
|
|