Merge pull request #5732

a96c1a46 cryptonote_protocol: drop peers we can't download from when syncing (moneromooo-monero)
ab361df2 p2p: add a few missing connection close calls (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-07-17 21:18:20 +02:00
commit 8eb075e789
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
2 changed files with 11 additions and 2 deletions

View file

@ -341,6 +341,11 @@ namespace cryptonote
if(m_core.have_block(hshd.top_id)) if(m_core.have_block(hshd.top_id))
{ {
if (target > hshd.current_height)
{
MINFO(context << "peer is not ahead of us and we're syncing, disconnecting");
return false;
}
context.m_state = cryptonote_connection_context::state_normal; context.m_state = cryptonote_connection_context::state_normal;
if(is_inital && target == m_core.get_current_blockchain_height()) if(is_inital && target == m_core.get_current_blockchain_height())
on_connection_synchronized(); on_connection_synchronized();

View file

@ -944,7 +944,10 @@ namespace nodetool
} }
if(!context.m_is_income) if(!context.m_is_income)
m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port); m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port);
m_payload_handler.process_payload_sync_data(rsp.payload_data, context, false); if (!m_payload_handler.process_payload_sync_data(rsp.payload_data, context, false))
{
m_network_zones.at(context.m_remote_address.get_zone()).m_net_server.get_config_object().close(context.m_connection_id );
}
}); });
if(!r) if(!r)
@ -1090,6 +1093,7 @@ namespace nodetool
LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer "
<< na.str() << na.str()
/*<< ", try " << try_count*/); /*<< ", try " << try_count*/);
zone.m_net_server.get_config_object().close(con->m_connection_id);
return false; return false;
} }
@ -1149,7 +1153,7 @@ namespace nodetool
bool is_priority = is_priority_node(na); bool is_priority = is_priority_node(na);
LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str()); LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str());
zone.m_net_server.get_config_object().close(con->m_connection_id);
return false; return false;
} }