Skip to content

Commit

Permalink
Move a number of forward declarations in to the fwd.hpp files.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Oct 30, 2024
1 parent a57f5d0 commit a7cfce1
Show file tree
Hide file tree
Showing 23 changed files with 91 additions and 160 deletions.
2 changes: 1 addition & 1 deletion nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ add_library(
epochs.hpp
errors.hpp
errors.cpp
fwd.hpp
id_dispenser.hpp
interval.hpp
ipc.hpp
Expand Down Expand Up @@ -97,7 +98,6 @@ add_library(
stats_enums.cpp
stats_sinks.hpp
stream.hpp
stream_fwd.hpp
thread_pool.hpp
thread_roles.hpp
thread_roles.cpp
Expand Down
8 changes: 1 addition & 7 deletions nano/lib/block_sideband.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#pragma once

#include <nano/lib/epoch.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/stream_fwd.hpp>
#include <nano/lib/timer.hpp>

#include <cstdint>
#include <memory>

namespace nano
{
enum class block_type : uint8_t;
class object_stream;
}

namespace nano
{
class block_details
Expand Down
10 changes: 1 addition & 9 deletions nano/lib/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <nano/lib/block_sideband.hpp>
#include <nano/lib/epoch.hpp>
#include <nano/lib/errors.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/optional_ptr.hpp>
#include <nano/lib/stream_fwd.hpp>

#include <boost/property_tree/ptree_fwd.hpp>

Expand All @@ -15,14 +15,6 @@ typedef struct blake2b_state__ blake2b_state;

namespace nano
{
class block;
class block_visitor;
class mutable_block_visitor;
class object_stream;
template <typename Key, typename Value>
class uniquer;
enum class work_version;

using block_uniquer = uniquer<nano::uint256_union, nano::block>;
}

Expand Down
31 changes: 31 additions & 0 deletions nano/lib/fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <cstdint>
#include <iosfwd>

struct uint8_char_traits;
namespace nano
{
class block;
enum class block_type : uint8_t;
class block_visitor;
class container_info;
enum class epoch : uint8_t;
class jsonconfig;
class mutable_block_visitor;
class network_constants;
class object_stream;
class thread_pool;
class tomlconfig;
template <typename Key, typename Value>
class uniquer;
enum class work_version;

using stream = std::basic_streambuf<uint8_t, uint8_char_traits>;
}

namespace nano::stat
{
enum class detail;
enum class dir;
}
10 changes: 0 additions & 10 deletions nano/lib/stream_fwd.hpp

This file was deleted.

5 changes: 0 additions & 5 deletions nano/node/bandwidth_limiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
#include <nano/node/fwd.hpp>
#include <nano/node/transport/traffic_type.hpp>

namespace nano
{
class node_config;
}

namespace nano
{
class bandwidth_limiter_config final
Expand Down
7 changes: 1 addition & 6 deletions nano/node/bootstrap_ascending/account_sets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <nano/lib/numbers.hpp>
#include <nano/node/bootstrap/bootstrap_config.hpp>
#include <nano/node/bootstrap_ascending/common.hpp>
#include <nano/node/fwd.hpp>

#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
Expand All @@ -16,12 +17,6 @@

namespace mi = boost::multi_index;

namespace nano
{
class account_sets_config;
class stats;
}

namespace nano
{
namespace bootstrap_ascending
Expand Down
9 changes: 1 addition & 8 deletions nano/node/confirming_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <nano/lib/thread_pool.hpp>
#include <nano/node/fwd.hpp>
#include <nano/secure/common.hpp>
#include <nano/secure/fwd.hpp>

#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
Expand All @@ -21,14 +22,6 @@

namespace mi = boost::multi_index;

namespace nano
{
class election;
class ledger;
class logger;
class stats;
}

namespace nano
{
class confirming_set_config final
Expand Down
16 changes: 4 additions & 12 deletions nano/node/epoch_upgrader.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
#pragma once

#include <nano/lib/fwd.hpp>
#include <nano/lib/locks.hpp>
#include <nano/lib/logging.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/node/fwd.hpp>
#include <nano/secure/fwd.hpp>
#include <nano/store/fwd.hpp>

#include <cstdint>
#include <future>

namespace nano
{
enum class epoch : uint8_t;
class network_params;
class node;
class ledger;
}
namespace nano::store
{
class component;
}

namespace nano
{
class epoch_upgrader final
Expand Down
15 changes: 5 additions & 10 deletions nano/node/fwd.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#pragma once

#include <nano/lib/fwd.hpp>
#include <nano/node/transport/fwd.hpp>
#include <nano/secure/fwd.hpp>
#include <nano/store/fwd.hpp>

// TODO: Move to lib/fwd.hpp
namespace nano
{
class block;
class container_info;
class thread_pool;
}

namespace nano
{
class account_sets_config;
class active_elections;
class block_processor;
class confirming_set;
class election;
class ledger;
class local_block_broadcaster;
class local_vote_history;
class logger;
Expand All @@ -35,6 +28,8 @@ class rep_crawler;
class rep_tiers;
class stats;
class vote_cache;
enum class vote_code;
enum class vote_source;
class vote_generator;
class vote_processor;
class vote_router;
Expand All @@ -53,4 +48,4 @@ class hinted;
class manual;
class optimistic;
class priority;
}
}
7 changes: 1 addition & 6 deletions nano/node/ipc/ipc_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

#include <nano/lib/config.hpp>
#include <nano/lib/errors.hpp>
#include <nano/lib/fwd.hpp>

#include <string>

namespace nano
{
class network_constants;
class tomlconfig;
}

namespace nano
{
namespace ipc
Expand Down
9 changes: 2 additions & 7 deletions nano/node/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <nano/lib/asio.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/errors.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/logging.hpp>
#include <nano/lib/memory.hpp>
#include <nano/lib/network_filter.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/object_stream.hpp>
#include <nano/lib/stats_enums.hpp>
#include <nano/lib/stream_fwd.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/secure/common.hpp>
#include <nano/secure/fwd.hpp>

#include <bitset>
#include <cstdint>
Expand All @@ -23,12 +24,6 @@

namespace nano
{
class block;
class jsonconfig;
template <typename Key, typename Value>
class uniquer;
class vote;

using block_uniquer = uniquer<nano::uint256_union, nano::block>;
using vote_uniquer = uniquer<nano::block_hash, nano::vote>;
}
Expand Down
6 changes: 5 additions & 1 deletion nano/node/transport/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ class tcp_channel;
class tcp_channels;
class tcp_server;
class tcp_socket;
}
}
namespace nano::transport::fake
{
class channel;
}
6 changes: 1 addition & 5 deletions nano/node/transport/tcp_listener.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <nano/lib/async.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/fwd.hpp>
#include <nano/node/transport/common.hpp>
Expand All @@ -20,11 +21,6 @@
namespace mi = boost::multi_index;
namespace asio = boost::asio;

namespace nano::stat
{
enum class dir;
}

namespace nano::transport
{
class tcp_config
Expand Down
13 changes: 2 additions & 11 deletions nano/node/vote_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/utility.hpp>
#include <nano/node/fwd.hpp>
#include <nano/secure/common.hpp>
#include <nano/secure/fwd.hpp>

#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
Expand All @@ -22,17 +24,6 @@

namespace mi = boost::multi_index;

namespace nano
{
class node;
class active_elections;
class election;
class stats;
class vote;
enum class vote_code;
enum class vote_source;
}

namespace nano
{
class vote_cache_config final
Expand Down
2 changes: 1 addition & 1 deletion nano/secure/account_info.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <nano/lib/epoch.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/stream_fwd.hpp>
#include <nano/lib/timer.hpp>

namespace nano
Expand Down
7 changes: 1 addition & 6 deletions nano/secure/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
#include <nano/lib/common.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/epochs.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/object_stream.hpp>
#include <nano/lib/stream_fwd.hpp>
#include <nano/lib/timer.hpp>
#include <nano/lib/utility.hpp>

#include <array>
#include <unordered_map>

namespace nano::stat
{
enum class detail;
}

namespace nano
{
/**
Expand Down
17 changes: 10 additions & 7 deletions nano/secure/fwd.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#pragma once

namespace nano
{
class account_info;
class ledger;
class ledger_cache;
class ledger_constants;
class network_params;
class vote;
}
namespace nano::secure
{
class read_transaction;
class transaction;
class write_transaction;
class read_transaction;
}

namespace nano
{
class account_info;
class vote;
}
Loading

0 comments on commit a7cfce1

Please sign in to comment.