Merge pull request #3723

16b20229 cryptonote_protocol_handler.inl: remove span read just now that failed to pass some basic tests (stoffu)
409bf2d6 cryptonote_protocol_handler.inl: fix return type mismatches (int vs bool) (stoffu)
pull/88/head
Riccardo Spagni 6 years ago
commit 715754d7fd
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD

@ -795,7 +795,7 @@ namespace cryptonote
relay_transactions(arg, context); relay_transactions(arg, context);
} }
return true; return 1;
} }
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
template<class t_core> template<class t_core>
@ -1008,6 +1008,7 @@ skip:
if (blocks.empty()) if (blocks.empty())
{ {
MERROR("Next span has no blocks"); MERROR("Next span has no blocks");
m_block_queue.remove_spans(span_connection_id, start_height);
break; break;
} }
@ -1015,6 +1016,7 @@ skip:
if (!parse_and_validate_block_from_blob(blocks.front().block, new_block)) if (!parse_and_validate_block_from_blob(blocks.front().block, new_block))
{ {
MERROR("Failed to parse block, but it should already have been parsed"); MERROR("Failed to parse block, but it should already have been parsed");
m_block_queue.remove_spans(span_connection_id, start_height);
break; break;
} }
bool parent_known = m_core.have_block(new_block.prev_id); bool parent_known = m_core.have_block(new_block.prev_id);
@ -1031,6 +1033,7 @@ skip:
// this can happen if a connection was sicced onto a late span, if it did not have those blocks, // this can happen if a connection was sicced onto a late span, if it did not have those blocks,
// since we don't know that at the sic time // since we don't know that at the sic time
LOG_ERROR_CCONTEXT("Got block with unknown parent which was not requested - querying block hashes"); LOG_ERROR_CCONTEXT("Got block with unknown parent which was not requested - querying block hashes");
m_block_queue.remove_spans(span_connection_id, start_height);
context.m_needed_objects.clear(); context.m_needed_objects.clear();
context.m_last_response_height = 0; context.m_last_response_height = 0;
goto skip; goto skip;
@ -1064,7 +1067,7 @@ skip:
if (tvc.size() != block_entry.txs.size()) if (tvc.size() != block_entry.txs.size())
{ {
LOG_ERROR_CCONTEXT("Internal error: tvc.size() != block_entry.txs.size()"); LOG_ERROR_CCONTEXT("Internal error: tvc.size() != block_entry.txs.size()");
return true; return 1;
} }
std::list<blobdata>::const_iterator it = block_entry.txs.begin(); std::list<blobdata>::const_iterator it = block_entry.txs.begin();
for (size_t i = 0; i < tvc.size(); ++i, ++it) for (size_t i = 0; i < tvc.size(); ++i, ++it)
@ -1075,7 +1078,7 @@ skip:
LOG_ERROR_CCONTEXT("transaction verification failed on NOTIFY_RESPONSE_GET_OBJECTS, tx_id = " LOG_ERROR_CCONTEXT("transaction verification failed on NOTIFY_RESPONSE_GET_OBJECTS, tx_id = "
<< epee::string_tools::pod_to_hex(get_blob_hash(*it)) << ", dropping connection"); << epee::string_tools::pod_to_hex(get_blob_hash(*it)) << ", dropping connection");
drop_connection(context, false, true); drop_connection(context, false, true);
return true; return 1;
})) }))
LOG_ERROR_CCONTEXT("span connection id not found"); LOG_ERROR_CCONTEXT("span connection id not found");
@ -1104,7 +1107,7 @@ skip:
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{ if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
LOG_PRINT_CCONTEXT_L1("Block verification failed, dropping connection"); LOG_PRINT_CCONTEXT_L1("Block verification failed, dropping connection");
drop_connection(context, true, true); drop_connection(context, true, true);
return true; return 1;
})) }))
LOG_ERROR_CCONTEXT("span connection id not found"); LOG_ERROR_CCONTEXT("span connection id not found");
@ -1123,7 +1126,7 @@ skip:
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{ if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
LOG_PRINT_CCONTEXT_L1("Block received at sync phase was marked as orphaned, dropping connection"); LOG_PRINT_CCONTEXT_L1("Block received at sync phase was marked as orphaned, dropping connection");
drop_connection(context, true, true); drop_connection(context, true, true);
return true; return 1;
})) }))
LOG_ERROR_CCONTEXT("span connection id not found"); LOG_ERROR_CCONTEXT("span connection id not found");
@ -1363,13 +1366,13 @@ skip:
MDEBUG(context << " we have the next span, and it is scheduled, resuming"); MDEBUG(context << " we have the next span, and it is scheduled, resuming");
++context.m_callback_request_count; ++context.m_callback_request_count;
m_p2p->request_callback(context); m_p2p->request_callback(context);
return 1; return true;
} }
for (size_t n = 0; n < 50; ++n) for (size_t n = 0; n < 50; ++n)
{ {
if (m_stopping) if (m_stopping)
return 1; return true;
boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
} }
} }
@ -1693,7 +1696,7 @@ skip:
m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, fluffyBlob, fluffyConnections); m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, fluffyBlob, fluffyConnections);
m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, fullBlob, fullConnections); m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, fullBlob, fullConnections);
return 1; return true;
} }
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
template<class t_core> template<class t_core>

Loading…
Cancel
Save