Skip to content

Commit

Permalink
Stop using boost::asio::ip::udp::endpoint (#4585)
Browse files Browse the repository at this point in the history
We are not using UDP anymore so there is no need to be referring to
boost::asio::ip::udp::endpoint.
  • Loading branch information
dsiganos authored Apr 26, 2024
1 parent 0505fb6 commit 30c1c8e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 50 deletions.
7 changes: 0 additions & 7 deletions nano/boost/asio/ip/udp.hpp

This file was deleted.

5 changes: 2 additions & 3 deletions nano/lib/common.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/boost/asio/ip/udp.hpp>

namespace nano
{
using endpoint = boost::asio::ip::udp::endpoint;
using tcp_endpoint = boost::asio::ip::tcp::endpoint;
using endpoint = boost::asio::ip::tcp::endpoint;
using tcp_endpoint = endpoint;
}
36 changes: 0 additions & 36 deletions nano/node/common.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/boost/asio/ip/udp.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/memory.hpp>
#include <nano/secure/common.hpp>
Expand All @@ -28,11 +27,6 @@ uint64_t endpoint_hash_raw (nano::endpoint const & endpoint_a)
uint64_t result (nano::ip_address_hash_raw (endpoint_a.address (), endpoint_a.port ()));
return result;
}
uint64_t endpoint_hash_raw (nano::tcp_endpoint const & endpoint_a)
{
uint64_t result (nano::ip_address_hash_raw (endpoint_a.address (), endpoint_a.port ()));
return result;
}

template <std::size_t size>
struct endpoint_hash
Expand All @@ -46,10 +40,6 @@ struct endpoint_hash<8>
{
return endpoint_hash_raw (endpoint_a);
}
std::size_t operator() (nano::tcp_endpoint const & endpoint_a) const
{
return endpoint_hash_raw (endpoint_a);
}
};

template <>
Expand All @@ -61,12 +51,6 @@ struct endpoint_hash<4>
uint32_t result (static_cast<uint32_t> (big) ^ static_cast<uint32_t> (big >> 32));
return result;
}
std::size_t operator() (nano::tcp_endpoint const & endpoint_a) const
{
uint64_t big (endpoint_hash_raw (endpoint_a));
uint32_t result (static_cast<uint32_t> (big) ^ static_cast<uint32_t> (big >> 32));
return result;
}
};

template <std::size_t size>
Expand Down Expand Up @@ -107,16 +91,6 @@ struct hash<::nano::endpoint>
}
};

template <>
struct hash<::nano::tcp_endpoint>
{
std::size_t operator() (::nano::tcp_endpoint const & endpoint_a) const
{
endpoint_hash<sizeof (std::size_t)> ehash;
return ehash (endpoint_a);
}
};

#ifndef BOOST_ASIO_HAS_STD_HASH
template <>
struct hash<boost::asio::ip::address>
Expand All @@ -142,16 +116,6 @@ struct hash<::nano::endpoint>
}
};

template <>
struct hash<::nano::tcp_endpoint>
{
std::size_t operator() (::nano::tcp_endpoint const & endpoint_a) const
{
std::hash<::nano::tcp_endpoint> hash;
return hash (endpoint_a);
}
};

template <>
struct hash<boost::asio::ip::address>
{
Expand Down
2 changes: 1 addition & 1 deletion nano/node/distributed_work.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void nano::distributed_work::start ()
else
{
auto this_l (shared_from_this ());
node.network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
node.network.resolver.async_resolve (boost::asio::ip::tcp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra] (boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator i_a) {
if (!ec)
{
this_l->do_request (nano::tcp_endpoint (i_a->endpoint ().address (), i_a->endpoint ().port ()));
Expand Down
2 changes: 1 addition & 1 deletion nano/node/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class network final
public:
nano::networks const id;
nano::syn_cookies syn_cookies;
boost::asio::ip::udp::resolver resolver;
boost::asio::ip::tcp::resolver resolver;
nano::peer_exclusion excluded_peers;
nano::network_filter publish_filter;
nano::transport::tcp_channels tcp_channels;
Expand Down
4 changes: 2 additions & 2 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ nano::outbound_bandwidth_limiter::config nano::outbound_bandwidth_limiter_config
void nano::node::keepalive (std::string const & address_a, uint16_t port_a)
{
auto node_l (shared_from_this ());
network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (address_a, std::to_string (port_a)), [node_l, address_a, port_a] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
network.resolver.async_resolve (boost::asio::ip::tcp::resolver::query (address_a, std::to_string (port_a)), [node_l, address_a, port_a] (boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator i_a) {
if (!ec)
{
for (auto i (i_a), n (boost::asio::ip::udp::resolver::iterator{}); i != n; ++i)
for (auto i (i_a), n (boost::asio::ip::tcp::resolver::iterator{}); i != n; ++i)
{
auto endpoint (nano::transport::map_endpoint_to_v6 (i->endpoint ()));
std::weak_ptr<nano::node> node_w (node_l);
Expand Down

0 comments on commit 30c1c8e

Please sign in to comment.