Skip to content
Permalink
Browse files

Fix backup seed node in p2p

  • Loading branch information...
miltonf committed Mar 26, 2019
1 parent 8fe68d1 commit d4bf16952ed805859605a3deca6358df0f240d5a
Showing with 11 additions and 3 deletions.
  1. +1 −0 src/p2p/net_node.h
  2. +10 −3 src/p2p/net_node.inl
@@ -315,6 +315,7 @@ namespace nodetool
std::list<epee::net_utils::network_address> m_priority_peers;
std::vector<epee::net_utils::network_address> m_exclusive_peers;
std::vector<epee::net_utils::network_address> m_seed_nodes;
bool m_fallback_seed_nodes_added;
std::list<nodetool::peerlist_entry> m_command_line_peers;
uint64_t m_peer_livetime;
//keep connections to initiate some interactions
@@ -405,6 +405,7 @@ namespace nodetool
bool res = handle_command_line(vm);
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");

m_fallback_seed_nodes_added = false;
if (m_nettype == cryptonote::TESTNET)
{
memcpy(&m_network_id, &::config::testnet::NETWORK_ID, 16);
@@ -498,6 +499,7 @@ namespace nodetool

for (const auto &peer: get_seed_nodes(cryptonote::MAINNET))
full_addrs.insert(peer);
m_fallback_seed_nodes_added = true;
}
}
}
@@ -1134,7 +1136,6 @@ namespace nodetool

size_t try_count = 0;
size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size();
bool fallback_nodes_added = false;
while(true)
{
if(m_net_server.is_stop_signal_sent())
@@ -1144,15 +1145,21 @@ namespace nodetool
break;
if(++try_count > m_seed_nodes.size())
{
if (!fallback_nodes_added)
if (!m_fallback_seed_nodes_added)
{
MWARNING("Failed to connect to any of seed peers, trying fallback seeds");
current_index = m_seed_nodes.size();
for (const auto &peer: get_seed_nodes(m_nettype))
{
MDEBUG("Fallback seed node: " << peer);
append_net_address(m_seed_nodes, peer);
}
fallback_nodes_added = true;
m_fallback_seed_nodes_added = true;
if (current_index == m_seed_nodes.size())
{
MWARNING("No fallback seeds, continuing without seeds");
break;
}
// continue for another few cycles
}
else

0 comments on commit d4bf169

Please sign in to comment.
You can’t perform that action at this time.