Rename nano/common.hpp to nano/endpoint.hpp and extract endpoint_templ.hpp template implementation file.

This commit is contained in:
Colin LeMahieu 2024-10-27 23:41:52 +00:00
commit d54e3d9915
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
40 changed files with 117 additions and 88 deletions

View file

@ -1,6 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/stream.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/test_common/testutil.hpp>
#include <gtest/gtest.h>

View file

@ -6,7 +6,7 @@
#include <nano/lib/stats.hpp>
#include <nano/lib/utility.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/make_store.hpp>
#include <nano/secure/common.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -4,7 +4,7 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>

View file

@ -1,7 +1,7 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/lib/stream.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/network.hpp>
#include <nano/test_common/testutil.hpp>

View file

@ -1,7 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/network_filter.hpp>
#include <nano/lib/stream.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/secure/common.hpp>
#include <nano/test_common/testutil.hpp>
@ -163,4 +163,4 @@ TEST (network_filter, expire)
ASSERT_FALSE (filter.check (2)); // Entry with epoch 1 should be expired
ASSERT_FALSE (filter.apply (2)); // Entry with epoch 1 should be replaced
}
}

View file

@ -1,5 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/vote_generator.hpp>
#include <nano/node/vote_spacing.hpp>

View file

@ -59,8 +59,6 @@ add_library(
bootstrap_ascending/service.cpp
cli.hpp
cli.cpp
common.hpp
common.cpp
confirming_set.hpp
confirming_set.cpp
confirmation_solicitor.hpp
@ -76,6 +74,9 @@ add_library(
election_behavior.hpp
election_insertion_result.hpp
election_status.hpp
endpoint.cpp
endpoint.hpp
endpoint_templ.hpp
epoch_upgrader.hpp
epoch_upgrader.cpp
fair_queue.hpp

View file

@ -1,7 +1,7 @@
#include <nano/node/bootstrap/bootstrap.hpp>
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
#include <nano/node/bootstrap/bootstrap_legacy.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/node.hpp>
#include <algorithm>

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/node/bootstrap/bootstrap_connections.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>

View file

@ -1,6 +1,6 @@
#pragma once
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <future>

View file

@ -2,7 +2,7 @@
#include <nano/node/bootstrap/bootstrap_attempt.hpp>
#include <nano/node/bootstrap/bootstrap_connections.hpp>
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/node.hpp>
#include <boost/format.hpp>

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/node/bootstrap/bootstrap_bulk_pull.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/transport/tcp_socket.hpp>
#include <atomic>

View file

@ -2,7 +2,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/bootstrap/bootstrap.hpp>
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/node.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp>

View file

@ -2,8 +2,8 @@
#include <nano/lib/cli.hpp>
#include <nano/lib/tomlconfig.hpp>
#include <nano/node/cli.hpp>
#include <nano/node/common.hpp>
#include <nano/node/daemonconfig.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/inactive_node.hpp>
#include <nano/node/node.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -7,7 +7,7 @@
#include <nano/lib/numbers.hpp>
#include <nano/lib/timer.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <optional>

View file

@ -2,8 +2,8 @@
#include <nano/lib/memory.hpp>
#include <nano/lib/stream.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/network.hpp>
#include <nano/node/wallet.hpp>
@ -27,6 +27,12 @@ uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint1
return result;
}
uint64_t nano::endpoint_hash_raw (nano::endpoint const & endpoint_a)
{
uint64_t result (nano::ip_address_hash_raw (endpoint_a.address (), endpoint_a.port ()));
return result;
}
bool nano::parse_port (std::string const & string_a, uint16_t & port_a)
{
bool result = false;

View file

@ -1,9 +1,10 @@
#pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/secure/common.hpp>
#include <cstdint>
#include <optional>
#include <string>
namespace boost::asio::ip
{
@ -19,16 +20,11 @@ bool parse_endpoint (std::string const &, nano::endpoint &);
std::optional<nano::endpoint> parse_endpoint (std::string const &);
bool parse_tcp_endpoint (std::string const &, nano::tcp_endpoint &);
uint64_t ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint16_t port = 0);
uint64_t endpoint_hash_raw (nano::endpoint const & endpoint_a);
}
namespace
{
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;
}
template <std::size_t size>
struct endpoint_hash
{
@ -39,7 +35,7 @@ struct endpoint_hash<8>
{
std::size_t operator() (nano::endpoint const & endpoint_a) const
{
return endpoint_hash_raw (endpoint_a);
return nano::endpoint_hash_raw (endpoint_a);
}
};
@ -48,7 +44,7 @@ struct endpoint_hash<4>
{
std::size_t operator() (nano::endpoint const & endpoint_a) const
{
uint64_t big (endpoint_hash_raw (endpoint_a));
uint64_t big = nano::endpoint_hash_raw (endpoint_a);
uint32_t result (static_cast<uint32_t> (big) ^ static_cast<uint32_t> (big >> 32));
return result;
}
@ -83,47 +79,19 @@ struct ip_address_hash<4>
namespace std
{
template <>
struct hash<::nano::endpoint>
{
std::size_t operator() (::nano::endpoint const & endpoint_a) const
{
endpoint_hash<sizeof (std::size_t)> ehash;
return ehash (endpoint_a);
}
};
struct hash<::nano::endpoint>;
#ifndef BOOST_ASIO_HAS_STD_HASH
template <>
struct hash<boost::asio::ip::address>
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
ip_address_hash<sizeof (std::size_t)> ihash;
return ihash (ip_a);
}
};
struct hash<boost::asio::ip::address>;
#endif
}
namespace boost
{
template <>
struct hash<::nano::endpoint>
{
std::size_t operator() (::nano::endpoint const & endpoint_a) const
{
std::hash<::nano::endpoint> hash;
return hash (endpoint_a);
}
};
struct hash<::nano::endpoint>;
template <>
struct hash<boost::asio::ip::address>
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
std::hash<boost::asio::ip::address> hash;
return hash (ip_a);
}
};
struct hash<boost::asio::ip::address>;
}

View file

@ -0,0 +1,52 @@
#pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/node/endpoint.hpp>
namespace std
{
template <>
struct hash<::nano::endpoint>
{
std::size_t operator() (::nano::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>
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
ip_address_hash<sizeof (std::size_t)> ihash;
return ihash (ip_a);
}
};
#endif
}
namespace boost
{
template <>
struct hash<::nano::endpoint>
{
std::size_t operator() (::nano::endpoint const & endpoint_a) const
{
std::hash<::nano::endpoint> hash;
return hash (endpoint_a);
}
};
template <>
struct hash<boost::asio::ip::address>
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
std::hash<boost::asio::ip::address> hash;
return hash (ip_a);
}
};
}

View file

@ -8,9 +8,9 @@
#include <nano/node/active_elections.hpp>
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
#include <nano/node/bootstrap_ascending/service.hpp>
#include <nano/node/common.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/json_handler.hpp>
#include <nano/node/node.hpp>
#include <nano/node/node_rpc_config.hpp>

View file

@ -8,8 +8,8 @@
#include <nano/lib/stream.hpp>
#include <nano/lib/utility.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/network.hpp>

View file

@ -1,5 +1,6 @@
#pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/lib/asio.hpp>
#include <nano/lib/block_uniquer.hpp>
#include <nano/lib/config.hpp>
@ -11,7 +12,7 @@
#include <nano/lib/object_stream.hpp>
#include <nano/lib/stats_enums.hpp>
#include <nano/lib/stream_fwd.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/secure/common.hpp>
#include <bitset>

View file

@ -2,7 +2,7 @@
#include <nano/lib/logging.hpp>
#include <nano/lib/network_filter.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/peer_exclusion.hpp>
#include <nano/node/transport/common.hpp>

View file

@ -11,10 +11,10 @@
#include <nano/node/bootstrap_ascending/service.hpp>
#include <nano/node/bootstrap_weights_beta.hpp>
#include <nano/node/bootstrap_weights_live.hpp>
#include <nano/node/common.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/node/daemonconfig.hpp>
#include <nano/node/election_status.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/local_block_broadcaster.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/make_store.hpp>

View file

@ -1,6 +1,7 @@
#pragma once
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/endpoint_templ.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/lib/locks.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/fwd.hpp>
#include <atomic>
@ -54,4 +54,4 @@ private:
nano::condition_variable condition;
std::thread thread;
};
}
}

View file

@ -1,7 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/stats.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/network.hpp>
#include <nano/node/node.hpp>

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/lib/utility.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/fwd.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/nodeconfig.hpp>

View file

@ -1,4 +1,4 @@
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/node.hpp>
#include <nano/node/transport/channel.hpp>
#include <nano/node/transport/transport.hpp>

View file

@ -4,7 +4,7 @@
#include <nano/lib/object_stream.hpp>
#include <nano/lib/stats.hpp>
#include <nano/node/bandwidth_limiter.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/transport/tcp_socket.hpp>
@ -140,4 +140,4 @@ private:
public: // Logging
virtual void operator() (nano::object_stream &) const;
};
}
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/lib/network_filter.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <memory>

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/lib/random.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/transport/channel.hpp>
#include <nano/node/transport/tcp_channel.hpp>
#include <nano/node/transport/transport.hpp>
@ -170,4 +170,4 @@ private:
mutable nano::random_generator rng;
};
}
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <nano/lib/async.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/fwd.hpp>
#include <nano/node/transport/common.hpp>
@ -176,4 +176,4 @@ private:
static std::string_view to_string (connection_type);
static nano::transport::socket_endpoint to_socket_endpoint (connection_type);
};
}
}

View file

@ -1,6 +1,6 @@
#pragma once
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/transport/fwd.hpp>
#include <nano/node/transport/tcp_socket.hpp>

View file

@ -1,4 +1,4 @@
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/node.hpp>
#include <nano/node/transport/transport.hpp>
@ -164,4 +164,4 @@ bool nano::transport::reserved_address (nano::endpoint const & endpoint_a, bool
}
}
return result;
}
}

View file

@ -3,7 +3,7 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/stats.hpp>
#include <nano/node/bandwidth_limiter.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/transport/tcp_socket.hpp>
@ -24,4 +24,4 @@ bool is_same_subnetwork (boost::asio::ip::address const &, boost::asio::ip::addr
// Unassigned, reserved, self
bool reserved_address (nano::endpoint const &, bool allow_local_peers = false);
}
}

View file

@ -2,7 +2,7 @@
#include <nano/lib/numbers.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/node/websocket_stream.hpp>
#include <nano/node/websocketconfig.hpp>

View file

@ -1,6 +1,6 @@
#include <nano/lib/logging.hpp>
#include <nano/lib/memory.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <gtest/gtest.h>

View file

@ -1,6 +1,6 @@
#pragma once
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/test_common/system.hpp>
namespace nano

View file

@ -2,7 +2,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/transport/tcp_listener.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp>

View file

@ -1,4 +1,4 @@
#include <nano/node/common.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/node/node.hpp>
#include <nano/test_common/telemetry.hpp>
@ -61,4 +61,4 @@ bool nano::test::compare_telemetry (const nano::telemetry_data & data, const nan
bool result = false;
compare_telemetry_impl (data, node, result);
return result;
}
}