Skip to content

Commit

Permalink
Rework add_initial_peers
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 16, 2024
1 parent 46fb760 commit 82e92cd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,15 +1116,22 @@ void nano::node::add_initial_peers ()
return;
}

auto transaction (store.tx_begin_read ());
for (auto i (store.peer.begin (transaction)), n (store.peer.end ()); i != n; ++i)
std::vector<nano::endpoint> initial_peers;
{
nano::endpoint endpoint (boost::asio::ip::address_v6 (i->first.address_bytes ()), i->first.port ());
if (network.track_reachout (endpoint))
auto transaction = store.tx_begin_read ();
for (auto i (store.peer.begin (transaction)), n (store.peer.end ()); i != n; ++i)
{
network.tcp_channels.start_tcp (endpoint);
nano::endpoint endpoint (boost::asio::ip::address_v6 (i->first.address_bytes ()), i->first.port ());
initial_peers.push_back (endpoint);
}
}

logger.info (nano::log::type::node, "Adding cached initial peers: {}", initial_peers.size ());

for (auto const & peer : initial_peers)
{
network.merge_peer (peer);
}
}

void nano::node::start_election (std::shared_ptr<nano::block> const & block)
Expand Down

0 comments on commit 82e92cd

Please # to comment.