diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b93fac654..4da28f153a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,8 @@ endif() if(MSVC) add_definitions(/MP) + add_definitions( + -D_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) # Suppress iterator warning endif() set(CPACK_PACKAGE_VENDOR "Nano Currency") diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index f592ea133c..cdf92cac11 100644 --- a/nano/core_test/active_elections.cpp +++ b/nano/core_test/active_elections.cpp @@ -6,11 +6,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/nano/core_test/block.cpp b/nano/core_test/block.cpp index f5dd614b3d..fe90835fea 100644 --- a/nano/core_test/block.cpp +++ b/nano/core_test/block.cpp @@ -1,6 +1,9 @@ +#include #include #include -#include +#include +#include +#include #include #include diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index 491741708f..1b085c394e 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -1,11 +1,12 @@ #include +#include #include #include #include #include #include #include -#include +#include #include #include #include diff --git a/nano/core_test/bootstrap_server.cpp b/nano/core_test/bootstrap_server.cpp index 659ecd46ba..45e493807a 100644 --- a/nano/core_test/bootstrap_server.cpp +++ b/nano/core_test/bootstrap_server.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/nano/core_test/conflicts.cpp b/nano/core_test/conflicts.cpp index 43c1938158..f9469f3bf0 100644 --- a/nano/core_test/conflicts.cpp +++ b/nano/core_test/conflicts.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/core_test/difficulty.cpp b/nano/core_test/difficulty.cpp index 2e65afacbf..77fbc418d8 100644 --- a/nano/core_test/difficulty.cpp +++ b/nano/core_test/difficulty.cpp @@ -1,8 +1,10 @@ +#include #include #include #include #include #include +#include #include #include diff --git a/nano/core_test/distributed_work.cpp b/nano/core_test/distributed_work.cpp index 6eb8437464..f5e040aa9a 100644 --- a/nano/core_test/distributed_work.cpp +++ b/nano/core_test/distributed_work.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/nano/core_test/entry.cpp b/nano/core_test/entry.cpp index 9d08284dd0..7c51ce85b9 100644 --- a/nano/core_test/entry.cpp +++ b/nano/core_test/entry.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/nano/core_test/fair_queue.cpp b/nano/core_test/fair_queue.cpp index 50fd6c8fc2..83366b1cea 100644 --- a/nano/core_test/fair_queue.cpp +++ b/nano/core_test/fair_queue.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/nano/core_test/fakes/work_peer.hpp b/nano/core_test/fakes/work_peer.hpp index bff40fee21..0e9e80f90d 100644 --- a/nano/core_test/fakes/work_peer.hpp +++ b/nano/core_test/fakes/work_peer.hpp @@ -4,7 +4,8 @@ #include #include #include -#include +#include +#include #include #include diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 0dd6e786db..d43d412690 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/core_test/memory_pool.cpp b/nano/core_test/memory_pool.cpp index 6d5dd4ae90..087f848947 100644 --- a/nano/core_test/memory_pool.cpp +++ b/nano/core_test/memory_pool.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include diff --git a/nano/core_test/message.cpp b/nano/core_test/message.cpp index 60d2338218..12ff989afd 100644 --- a/nano/core_test/message.cpp +++ b/nano/core_test/message.cpp @@ -1,8 +1,9 @@ #include #include #include -#include +#include #include +#include #include #include diff --git a/nano/core_test/message_deserializer.cpp b/nano/core_test/message_deserializer.cpp index 44e9fa06df..7d65d6528a 100644 --- a/nano/core_test/message_deserializer.cpp +++ b/nano/core_test/message_deserializer.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 3ae42f764b..1037580eb2 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/core_test/network_filter.cpp b/nano/core_test/network_filter.cpp index 788d7c2715..8765b11180 100644 --- a/nano/core_test/network_filter.cpp +++ b/nano/core_test/network_filter.cpp @@ -1,7 +1,8 @@ #include #include #include -#include +#include +#include #include #include @@ -163,4 +164,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 -} \ No newline at end of file +} diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 377d61ed54..87f91c04bd 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -3814,4 +3816,4 @@ TEST (node, container_info) // This should just execute, sanitizers will catch any problems ASSERT_NO_THROW (node1.container_info ()); ASSERT_NO_THROW (node2.container_info ()); -} \ No newline at end of file +} diff --git a/nano/core_test/numbers.cpp b/nano/core_test/numbers.cpp index a30b2eb108..ec8bed3f4e 100644 --- a/nano/core_test/numbers.cpp +++ b/nano/core_test/numbers.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -647,4 +648,4 @@ TEST (uint512_union, hash) ASSERT_NE (h (x1), h (x2)); } } -} \ No newline at end of file +} diff --git a/nano/core_test/rep_crawler.cpp b/nano/core_test/rep_crawler.cpp index 1d52769df9..e9d0ba8d41 100644 --- a/nano/core_test/rep_crawler.cpp +++ b/nano/core_test/rep_crawler.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -327,4 +328,4 @@ TEST (rep_crawler, ignore_rebroadcasted) }; ASSERT_NEVER (1s, tick () || node1.rep_crawler.representative_count () > 0); -} \ No newline at end of file +} diff --git a/nano/core_test/request_aggregator.cpp b/nano/core_test/request_aggregator.cpp index 2f85074e40..5e99210c28 100644 --- a/nano/core_test/request_aggregator.cpp +++ b/nano/core_test/request_aggregator.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/core_test/system.cpp b/nano/core_test/system.cpp index 7f9f1088a0..0ac3c28a3e 100644 --- a/nano/core_test/system.cpp +++ b/nano/core_test/system.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/nano/core_test/telemetry.cpp b/nano/core_test/telemetry.cpp index 2d120fe260..859d3ffb39 100644 --- a/nano/core_test/telemetry.cpp +++ b/nano/core_test/telemetry.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/nano/core_test/vote_processor.cpp b/nano/core_test/vote_processor.cpp index 3f656794e8..aa8b7e7578 100644 --- a/nano/core_test/vote_processor.cpp +++ b/nano/core_test/vote_processor.cpp @@ -2,10 +2,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include diff --git a/nano/core_test/voting.cpp b/nano/core_test/voting.cpp index 3389a8a96f..55d63259fc 100644 --- a/nano/core_test/voting.cpp +++ b/nano/core_test/voting.cpp @@ -1,9 +1,10 @@ #include -#include +#include #include #include #include #include +#include #include #include diff --git a/nano/core_test/wallet.cpp b/nano/core_test/wallet.cpp index e9e170f6d5..79068966e8 100644 --- a/nano/core_test/wallet.cpp +++ b/nano/core_test/wallet.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/core_test/websocket.cpp b/nano/core_test/websocket.cpp index 90991493d3..fd527f8fa4 100644 --- a/nano/core_test/websocket.cpp +++ b/nano/core_test/websocket.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include #include diff --git a/nano/core_test/work_pool.cpp b/nano/core_test/work_pool.cpp index 63eae4cf7f..cb4eed4606 100644 --- a/nano/core_test/work_pool.cpp +++ b/nano/core_test/work_pool.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/lib/CMakeLists.txt b/nano/lib/CMakeLists.txt index 76d53944f0..748df54398 100644 --- a/nano/lib/CMakeLists.txt +++ b/nano/lib/CMakeLists.txt @@ -33,6 +33,7 @@ add_library( char_traits.hpp cli.hpp cli.cpp + common.hpp config.hpp config.cpp configbase.hpp @@ -44,8 +45,11 @@ add_library( env.cpp epoch.hpp epoch.cpp + epochs.cpp + epochs.hpp errors.hpp errors.cpp + fwd.hpp id_dispenser.hpp interval.hpp ipc.hpp @@ -69,6 +73,7 @@ add_library( network_filter.cpp numbers.hpp numbers.cpp + numbers_templ.hpp object_stream.hpp object_stream.cpp object_stream_adapters.hpp @@ -110,7 +115,8 @@ add_library( walletconfig.hpp walletconfig.cpp work.hpp - work.cpp) + work.cpp + work_version.hpp) include_directories(${CMAKE_SOURCE_DIR}/submodules) include_directories( diff --git a/nano/lib/block_sideband.cpp b/nano/lib/block_sideband.cpp index e69de29bb2..8b37f71dba 100644 --- a/nano/lib/block_sideband.cpp +++ b/nano/lib/block_sideband.cpp @@ -0,0 +1,216 @@ +#include +#include +#include +#include + +#include + +/* + * block_details + */ + +nano::block_details::block_details (nano::epoch const epoch_a, bool const is_send_a, bool const is_receive_a, bool const is_epoch_a) : + epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a) +{ +} + +bool nano::block_details::operator== (nano::block_details const & other_a) const +{ + return epoch == other_a.epoch && is_send == other_a.is_send && is_receive == other_a.is_receive && is_epoch == other_a.is_epoch; +} + +uint8_t nano::block_details::packed () const +{ + std::bitset<8> result (static_cast (epoch)); + result.set (7, is_send); + result.set (6, is_receive); + result.set (5, is_epoch); + return static_cast (result.to_ulong ()); +} + +void nano::block_details::unpack (uint8_t details_a) +{ + constexpr std::bitset<8> epoch_mask{ 0b00011111 }; + auto as_bitset = static_cast> (details_a); + is_send = as_bitset.test (7); + is_receive = as_bitset.test (6); + is_epoch = as_bitset.test (5); + epoch = static_cast ((as_bitset & epoch_mask).to_ulong ()); +} + +void nano::block_details::serialize (nano::stream & stream_a) const +{ + nano::write (stream_a, packed ()); +} + +bool nano::block_details::deserialize (nano::stream & stream_a) +{ + bool result (false); + try + { + uint8_t packed{ 0 }; + nano::read (stream_a, packed); + unpack (packed); + } + catch (std::runtime_error &) + { + result = true; + } + + return result; +} + +void nano::block_details::operator() (nano::object_stream & obs) const +{ + obs.write ("epoch", epoch); + obs.write ("is_send", is_send); + obs.write ("is_receive", is_receive); + obs.write ("is_epoch", is_epoch); +} + +std::string nano::state_subtype (nano::block_details const details_a) +{ + debug_assert (details_a.is_epoch + details_a.is_receive + details_a.is_send <= 1); + if (details_a.is_send) + { + return "send"; + } + else if (details_a.is_receive) + { + return "receive"; + } + else if (details_a.is_epoch) + { + return "epoch"; + } + else + { + return "change"; + } +} + +/* + * block_sideband + */ + +nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, nano::seconds_t const timestamp_a, nano::block_details const & details_a, nano::epoch const source_epoch_a) : + successor (successor_a), + account (account_a), + balance (balance_a), + height (height_a), + timestamp (timestamp_a), + details (details_a), + source_epoch (source_epoch_a) +{ +} + +nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, nano::seconds_t const timestamp_a, nano::epoch const epoch_a, bool const is_send, bool const is_receive, bool const is_epoch, nano::epoch const source_epoch_a) : + successor (successor_a), + account (account_a), + balance (balance_a), + height (height_a), + timestamp (timestamp_a), + details (epoch_a, is_send, is_receive, is_epoch), + source_epoch (source_epoch_a) +{ +} + +size_t nano::block_sideband::size (nano::block_type type_a) +{ + size_t result (0); + result += sizeof (successor); + if (type_a != nano::block_type::state && type_a != nano::block_type::open) + { + result += sizeof (account); + } + if (type_a != nano::block_type::open) + { + result += sizeof (height); + } + if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) + { + result += sizeof (balance); + } + result += sizeof (timestamp); + if (type_a == nano::block_type::state) + { + static_assert (sizeof (nano::epoch) == nano::block_details::size (), "block_details is larger than the epoch enum"); + result += nano::block_details::size () + sizeof (nano::epoch); + } + return result; +} + +void nano::block_sideband::serialize (nano::stream & stream_a, nano::block_type type_a) const +{ + nano::write (stream_a, successor.bytes); + if (type_a != nano::block_type::state && type_a != nano::block_type::open) + { + nano::write (stream_a, account.bytes); + } + if (type_a != nano::block_type::open) + { + nano::write (stream_a, boost::endian::native_to_big (height)); + } + if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) + { + nano::write (stream_a, balance.bytes); + } + nano::write (stream_a, boost::endian::native_to_big (timestamp)); + if (type_a == nano::block_type::state) + { + details.serialize (stream_a); + nano::write (stream_a, static_cast (source_epoch)); + } +} + +bool nano::block_sideband::deserialize (nano::stream & stream_a, nano::block_type type_a) +{ + bool result (false); + try + { + nano::read (stream_a, successor.bytes); + if (type_a != nano::block_type::state && type_a != nano::block_type::open) + { + nano::read (stream_a, account.bytes); + } + if (type_a != nano::block_type::open) + { + nano::read (stream_a, height); + boost::endian::big_to_native_inplace (height); + } + else + { + height = 1; + } + if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) + { + nano::read (stream_a, balance.bytes); + } + nano::read (stream_a, timestamp); + boost::endian::big_to_native_inplace (timestamp); + if (type_a == nano::block_type::state) + { + result = details.deserialize (stream_a); + uint8_t source_epoch_uint8_t{ 0 }; + nano::read (stream_a, source_epoch_uint8_t); + source_epoch = static_cast (source_epoch_uint8_t); + } + } + catch (std::runtime_error &) + { + result = true; + } + + return result; +} + +void nano::block_sideband::operator() (nano::object_stream & obs) const +{ + obs.write ("successor", successor); + obs.write ("account", account); + obs.write ("balance", balance); + obs.write ("height", height); + obs.write ("timestamp", timestamp); + obs.write ("source_epoch", source_epoch); + obs.write ("details", details); +} diff --git a/nano/lib/block_sideband.hpp b/nano/lib/block_sideband.hpp index 871f9bfcfc..09dcc8a96a 100644 --- a/nano/lib/block_sideband.hpp +++ b/nano/lib/block_sideband.hpp @@ -1,19 +1,13 @@ #pragma once -#include #include +#include #include -#include #include #include #include -namespace nano -{ -class object_stream; -} - namespace nano { class block_details diff --git a/nano/lib/block_type.cpp b/nano/lib/block_type.cpp index 70ec28b40c..5be00af002 100644 --- a/nano/lib/block_type.cpp +++ b/nano/lib/block_type.cpp @@ -5,8 +5,3 @@ std::string_view nano::to_string (nano::block_type type) { return nano::enum_util::name (type); } - -void nano::serialize_block_type (nano::stream & stream, const nano::block_type & type) -{ - nano::write (stream, type); -} diff --git a/nano/lib/block_type.hpp b/nano/lib/block_type.hpp index 020722e315..591c799992 100644 --- a/nano/lib/block_type.hpp +++ b/nano/lib/block_type.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include #include @@ -19,8 +17,4 @@ enum class block_type : uint8_t }; std::string_view to_string (block_type); -/** - * Serialize block type as an 8-bit value - */ -void serialize_block_type (nano::stream &, nano::block_type const &); } // namespace nano diff --git a/nano/lib/block_uniquer.hpp b/nano/lib/block_uniquer.hpp index d39bb3afc4..4a0c7076b9 100644 --- a/nano/lib/block_uniquer.hpp +++ b/nano/lib/block_uniquer.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace nano diff --git a/nano/lib/blocks.cpp b/nano/lib/blocks.cpp index 4fc527eb0d..d61233e4a1 100644 --- a/nano/lib/blocks.cpp +++ b/nano/lib/blocks.cpp @@ -1,9 +1,13 @@ #include +#include +#include #include #include #include #include +#include #include +#include #include #include @@ -1582,7 +1586,7 @@ std::shared_ptr nano::deserialize_block_json (boost::property_tree: void nano::serialize_block (nano::stream & stream_a, nano::block const & block_a) { - nano::serialize_block_type (stream_a, block_a.type ()); + nano::write (stream_a, block_a.type ()); block_a.serialize (stream_a); } @@ -1908,213 +1912,3 @@ void nano::receive_block::operator() (nano::object_stream & obs) const obs.write ("signature", signature); obs.write ("work", work); } - -/* - * block_details - */ - -nano::block_details::block_details (nano::epoch const epoch_a, bool const is_send_a, bool const is_receive_a, bool const is_epoch_a) : - epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a) -{ -} - -bool nano::block_details::operator== (nano::block_details const & other_a) const -{ - return epoch == other_a.epoch && is_send == other_a.is_send && is_receive == other_a.is_receive && is_epoch == other_a.is_epoch; -} - -uint8_t nano::block_details::packed () const -{ - std::bitset<8> result (static_cast (epoch)); - result.set (7, is_send); - result.set (6, is_receive); - result.set (5, is_epoch); - return static_cast (result.to_ulong ()); -} - -void nano::block_details::unpack (uint8_t details_a) -{ - constexpr std::bitset<8> epoch_mask{ 0b00011111 }; - auto as_bitset = static_cast> (details_a); - is_send = as_bitset.test (7); - is_receive = as_bitset.test (6); - is_epoch = as_bitset.test (5); - epoch = static_cast ((as_bitset & epoch_mask).to_ulong ()); -} - -void nano::block_details::serialize (nano::stream & stream_a) const -{ - nano::write (stream_a, packed ()); -} - -bool nano::block_details::deserialize (nano::stream & stream_a) -{ - bool result (false); - try - { - uint8_t packed{ 0 }; - nano::read (stream_a, packed); - unpack (packed); - } - catch (std::runtime_error &) - { - result = true; - } - - return result; -} - -void nano::block_details::operator() (nano::object_stream & obs) const -{ - obs.write ("epoch", epoch); - obs.write ("is_send", is_send); - obs.write ("is_receive", is_receive); - obs.write ("is_epoch", is_epoch); -} - -std::string nano::state_subtype (nano::block_details const details_a) -{ - debug_assert (details_a.is_epoch + details_a.is_receive + details_a.is_send <= 1); - if (details_a.is_send) - { - return "send"; - } - else if (details_a.is_receive) - { - return "receive"; - } - else if (details_a.is_epoch) - { - return "epoch"; - } - else - { - return "change"; - } -} - -/* - * block_sideband - */ - -nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, nano::seconds_t const timestamp_a, nano::block_details const & details_a, nano::epoch const source_epoch_a) : - successor (successor_a), - account (account_a), - balance (balance_a), - height (height_a), - timestamp (timestamp_a), - details (details_a), - source_epoch (source_epoch_a) -{ -} - -nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, nano::seconds_t const timestamp_a, nano::epoch const epoch_a, bool const is_send, bool const is_receive, bool const is_epoch, nano::epoch const source_epoch_a) : - successor (successor_a), - account (account_a), - balance (balance_a), - height (height_a), - timestamp (timestamp_a), - details (epoch_a, is_send, is_receive, is_epoch), - source_epoch (source_epoch_a) -{ -} - -size_t nano::block_sideband::size (nano::block_type type_a) -{ - size_t result (0); - result += sizeof (successor); - if (type_a != nano::block_type::state && type_a != nano::block_type::open) - { - result += sizeof (account); - } - if (type_a != nano::block_type::open) - { - result += sizeof (height); - } - if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) - { - result += sizeof (balance); - } - result += sizeof (timestamp); - if (type_a == nano::block_type::state) - { - static_assert (sizeof (nano::epoch) == nano::block_details::size (), "block_details is larger than the epoch enum"); - result += nano::block_details::size () + sizeof (nano::epoch); - } - return result; -} - -void nano::block_sideband::serialize (nano::stream & stream_a, nano::block_type type_a) const -{ - nano::write (stream_a, successor.bytes); - if (type_a != nano::block_type::state && type_a != nano::block_type::open) - { - nano::write (stream_a, account.bytes); - } - if (type_a != nano::block_type::open) - { - nano::write (stream_a, boost::endian::native_to_big (height)); - } - if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) - { - nano::write (stream_a, balance.bytes); - } - nano::write (stream_a, boost::endian::native_to_big (timestamp)); - if (type_a == nano::block_type::state) - { - details.serialize (stream_a); - nano::write (stream_a, static_cast (source_epoch)); - } -} - -bool nano::block_sideband::deserialize (nano::stream & stream_a, nano::block_type type_a) -{ - bool result (false); - try - { - nano::read (stream_a, successor.bytes); - if (type_a != nano::block_type::state && type_a != nano::block_type::open) - { - nano::read (stream_a, account.bytes); - } - if (type_a != nano::block_type::open) - { - nano::read (stream_a, height); - boost::endian::big_to_native_inplace (height); - } - else - { - height = 1; - } - if (type_a == nano::block_type::receive || type_a == nano::block_type::change || type_a == nano::block_type::open) - { - nano::read (stream_a, balance.bytes); - } - nano::read (stream_a, timestamp); - boost::endian::big_to_native_inplace (timestamp); - if (type_a == nano::block_type::state) - { - result = details.deserialize (stream_a); - uint8_t source_epoch_uint8_t{ 0 }; - nano::read (stream_a, source_epoch_uint8_t); - source_epoch = static_cast (source_epoch_uint8_t); - } - } - catch (std::runtime_error &) - { - result = true; - } - - return result; -} - -void nano::block_sideband::operator() (nano::object_stream & obs) const -{ - obs.write ("successor", successor); - obs.write ("account", account); - obs.write ("balance", balance); - obs.write ("height", height); - obs.write ("timestamp", timestamp); - obs.write ("source_epoch", source_epoch); - obs.write ("details", details); -} diff --git a/nano/lib/blocks.hpp b/nano/lib/blocks.hpp index 2312855cb6..14524e556d 100644 --- a/nano/lib/blocks.hpp +++ b/nano/lib/blocks.hpp @@ -1,24 +1,25 @@ #pragma once #include -#include -#include #include #include +#include #include #include -#include #include +#include + typedef struct blake2b_state__ blake2b_state; namespace nano { -class block_visitor; -class mutable_block_visitor; -class object_stream; +using block_uniquer = uniquer; +} +namespace nano +{ class block { public: diff --git a/nano/lib/common.hpp b/nano/lib/common.hpp index bd1f309948..1e54097d05 100644 --- a/nano/lib/common.hpp +++ b/nano/lib/common.hpp @@ -1,9 +1,14 @@ #pragma once -#include +namespace boost::asio::ip +{ +class tcp; +template +class basic_endpoint; +} namespace nano { -using endpoint = boost::asio::ip::tcp::endpoint; +using endpoint = boost::asio::ip::basic_endpoint; using tcp_endpoint = endpoint; -} \ No newline at end of file +} diff --git a/nano/lib/config.cpp b/nano/lib/config.cpp index 4dda3dcf15..41b73e5106 100644 --- a/nano/lib/config.cpp +++ b/nano/lib/config.cpp @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include #include diff --git a/nano/lib/config.hpp b/nano/lib/config.hpp index c67095967b..239f5ad8ce 100644 --- a/nano/lib/config.hpp +++ b/nano/lib/config.hpp @@ -105,15 +105,11 @@ enum class networks : uint16_t std::string_view to_string (nano::networks); -enum class work_version -{ - unspecified, - work_1 -}; enum class block_type : uint8_t; class root; class block; class block_details; +enum class work_version; class work_thresholds { diff --git a/nano/lib/epoch.cpp b/nano/lib/epoch.cpp index 8fb6cd20f4..1de1a0476f 100644 --- a/nano/lib/epoch.cpp +++ b/nano/lib/epoch.cpp @@ -1,43 +1,6 @@ #include #include -#include - -nano::link const & nano::epochs::link (nano::epoch epoch_a) const -{ - return epochs_m.at (epoch_a).link; -} - -bool nano::epochs::is_epoch_link (nano::link const & link_a) const -{ - return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; }); -} - -nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const -{ - return epochs_m.at (epoch_a).signer; -} - -nano::epoch nano::epochs::epoch (nano::link const & link_a) const -{ - auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; })); - debug_assert (existing != epochs_m.end ()); - return existing->first; -} - -void nano::epochs::add (nano::epoch epoch_a, nano::public_key const & signer_a, nano::link const & link_a) -{ - debug_assert (epochs_m.find (epoch_a) == epochs_m.end ()); - epochs_m[epoch_a] = { signer_a, link_a }; -} - -bool nano::epochs::is_sequential (nano::epoch epoch_a, nano::epoch new_epoch_a) -{ - auto head_epoch = std::underlying_type_t (epoch_a); - bool is_valid_epoch (head_epoch >= std::underlying_type_t (nano::epoch::epoch_0)); - return is_valid_epoch && (std::underlying_type_t (new_epoch_a) == (head_epoch + 1)); -} - std::underlying_type_t nano::normalized_epoch (nano::epoch epoch_a) { // Currently assumes that the epoch versions in the enum are sequential. diff --git a/nano/lib/epoch.hpp b/nano/lib/epoch.hpp index df0a24f7ba..4fae5e1a52 100644 --- a/nano/lib/epoch.hpp +++ b/nano/lib/epoch.hpp @@ -1,9 +1,8 @@ #pragma once -#include - +#include +#include #include -#include namespace nano { @@ -31,42 +30,7 @@ struct hash<::nano::epoch> { std::size_t operator() (::nano::epoch const & epoch_a) const { - std::hash> hash; - return hash (static_cast> (epoch_a)); + return std::underlying_type_t<::nano::epoch> (epoch_a); } }; } -namespace nano -{ -class epoch_info -{ -public: - nano::public_key signer; - nano::link link; -}; -class epochs -{ -public: - /** Returns true if link matches one of the released epoch links. - * WARNING: just because a legal block contains an epoch link, it does not mean it is an epoch block. - * A legal block containing an epoch link can easily be constructed by sending to an address identical - * to one of the epoch links. - * Epoch blocks follow the following rules and a block must satisfy them all to be a true epoch block: - * epoch blocks are always state blocks - * epoch blocks never change the balance of an account - * epoch blocks always have a link field that starts with the ascii bytes "epoch v1 block" or "epoch v2 block" (and possibly others in the future) - * epoch blocks never change the representative - * epoch blocks are not signed by the account key, they are signed either by genesis or by special epoch keys - */ - bool is_epoch_link (nano::link const & link_a) const; - nano::link const & link (nano::epoch epoch_a) const; - nano::public_key const & signer (nano::epoch epoch_a) const; - nano::epoch epoch (nano::link const & link_a) const; - void add (nano::epoch epoch_a, nano::public_key const & signer_a, nano::link const & link_a); - /** Checks that new_epoch is 1 version higher than epoch */ - static bool is_sequential (nano::epoch epoch_a, nano::epoch new_epoch_a); - -private: - std::unordered_map epochs_m; -}; -} diff --git a/nano/lib/epochs.cpp b/nano/lib/epochs.cpp new file mode 100644 index 0000000000..426d5ab10d --- /dev/null +++ b/nano/lib/epochs.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include + +nano::link const & nano::epochs::link (nano::epoch epoch_a) const +{ + return epochs_m.at (epoch_a).link; +} + +bool nano::epochs::is_epoch_link (nano::link const & link_a) const +{ + return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; }); +} + +nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const +{ + return epochs_m.at (epoch_a).signer; +} + +nano::epoch nano::epochs::epoch (nano::link const & link_a) const +{ + auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; })); + debug_assert (existing != epochs_m.end ()); + return existing->first; +} + +void nano::epochs::add (nano::epoch epoch_a, nano::public_key const & signer_a, nano::link const & link_a) +{ + debug_assert (epochs_m.find (epoch_a) == epochs_m.end ()); + epochs_m[epoch_a] = { signer_a, link_a }; +} + +bool nano::epochs::is_sequential (nano::epoch epoch_a, nano::epoch new_epoch_a) +{ + auto head_epoch = std::underlying_type_t (epoch_a); + bool is_valid_epoch (head_epoch >= std::underlying_type_t (nano::epoch::epoch_0)); + return is_valid_epoch && (std::underlying_type_t (new_epoch_a) == (head_epoch + 1)); +} diff --git a/nano/lib/epochs.hpp b/nano/lib/epochs.hpp new file mode 100644 index 0000000000..c81ade7f2d --- /dev/null +++ b/nano/lib/epochs.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include +#include + +namespace nano +{ +class epoch_info +{ +public: + nano::public_key signer; + nano::link link; +}; +class epochs +{ +public: + /** Returns true if link matches one of the released epoch links. + * WARNING: just because a legal block contains an epoch link, it does not mean it is an epoch block. + * A legal block containing an epoch link can easily be constructed by sending to an address identical + * to one of the epoch links. + * Epoch blocks follow the following rules and a block must satisfy them all to be a true epoch block: + * epoch blocks are always state blocks + * epoch blocks never change the balance of an account + * epoch blocks always have a link field that starts with the ascii bytes "epoch v1 block" or "epoch v2 block" (and possibly others in the future) + * epoch blocks never change the representative + * epoch blocks are not signed by the account key, they are signed either by genesis or by special epoch keys + */ + bool is_epoch_link (nano::link const & link_a) const; + nano::link const & link (nano::epoch epoch_a) const; + nano::public_key const & signer (nano::epoch epoch_a) const; + nano::epoch epoch (nano::link const & link_a) const; + void add (nano::epoch epoch_a, nano::public_key const & signer_a, nano::link const & link_a); + /** Checks that new_epoch is 1 version higher than epoch */ + static bool is_sequential (nano::epoch epoch_a, nano::epoch new_epoch_a); + +private: + std::unordered_map epochs_m; +}; +} diff --git a/nano/lib/fwd.hpp b/nano/lib/fwd.hpp new file mode 100644 index 0000000000..0409d7629d --- /dev/null +++ b/nano/lib/fwd.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +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 +class uniquer; +enum class work_version; + +using stream = std::basic_streambuf; +} + +namespace nano::stat +{ +enum class detail; +enum class dir; +} diff --git a/nano/lib/memory.hpp b/nano/lib/memory.hpp index 333a5ff980..3d0a248a22 100644 --- a/nano/lib/memory.hpp +++ b/nano/lib/memory.hpp @@ -48,6 +48,16 @@ class cleanup_guard final std::vector> cleanup_funcs; }; +/** Helper guard which contains all the necessary purge (remove all memory even if used) functions */ +class node_singleton_memory_pool_purge_guard +{ +public: + node_singleton_memory_pool_purge_guard (); + +private: + nano::cleanup_guard cleanup_guard; +}; + template std::shared_ptr make_shared (Args &&... args) { diff --git a/nano/lib/network_filter.hpp b/nano/lib/network_filter.hpp index c9cca1030f..84cb65f412 100644 --- a/nano/lib/network_filter.hpp +++ b/nano/lib/network_filter.hpp @@ -1,6 +1,7 @@ #pragma once +#include #include #include diff --git a/nano/lib/numbers.hpp b/nano/lib/numbers.hpp index bf8137c657..ccf42ba357 100644 --- a/nano/lib/numbers.hpp +++ b/nano/lib/numbers.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -516,185 +516,53 @@ namespace difficulty namespace std { template <> -struct hash<::nano::uint128_union> -{ - size_t operator() (::nano::uint128_union const & value) const noexcept - { - return value.qwords[0] + value.qwords[1]; - } -}; +struct hash<::nano::uint128_union>; template <> -struct hash<::nano::uint256_union> -{ - size_t operator() (::nano::uint256_union const & value) const noexcept - { - return value.qwords[0] + value.qwords[1] + value.qwords[2] + value.qwords[3]; - } -}; +struct hash<::nano::uint256_union>; template <> -struct hash<::nano::public_key> -{ - size_t operator() (::nano::public_key const & value) const noexcept - { - return hash<::nano::uint256_union>{}(value); - } -}; +struct hash<::nano::public_key>; template <> -struct hash<::nano::block_hash> -{ - size_t operator() (::nano::block_hash const & value) const noexcept - { - return hash<::nano::uint256_union>{}(value); - } -}; +struct hash<::nano::block_hash>; template <> -struct hash<::nano::hash_or_account> -{ - size_t operator() (::nano::hash_or_account const & value) const noexcept - { - return hash<::nano::block_hash>{}(value.as_block_hash ()); - } -}; +struct hash<::nano::hash_or_account>; template <> -struct hash<::nano::root> -{ - size_t operator() (::nano::root const & value) const noexcept - { - return hash<::nano::hash_or_account>{}(value); - } -}; +struct hash<::nano::root>; template <> -struct hash<::nano::link> -{ - size_t operator() (::nano::link const & value) const noexcept - { - return hash<::nano::hash_or_account>{}(value); - } -}; +struct hash<::nano::link>; template <> -struct hash<::nano::raw_key> -{ - size_t operator() (::nano::raw_key const & value) const noexcept - { - return hash<::nano::uint256_union>{}(value); - } -}; +struct hash<::nano::raw_key>; template <> -struct hash<::nano::wallet_id> -{ - size_t operator() (::nano::wallet_id const & value) const noexcept - { - return hash<::nano::uint256_union>{}(value); - } -}; +struct hash<::nano::wallet_id>; template <> -struct hash<::nano::uint512_union> -{ - size_t operator() (::nano::uint512_union const & value) const noexcept - { - return hash<::nano::uint256_union>{}(value.uint256s[0]) + hash<::nano::uint256_union> () (value.uint256s[1]); - } -}; +struct hash<::nano::uint512_union>; template <> -struct hash<::nano::qualified_root> -{ - size_t operator() (::nano::qualified_root const & value) const noexcept - { - return hash<::nano::uint512_union>{}(value); - } -}; +struct hash<::nano::qualified_root>; } namespace boost { template <> -struct hash<::nano::uint128_union> -{ - size_t operator() (::nano::uint128_union const & value) const noexcept - { - return std::hash<::nano::uint128_union> () (value); - } -}; +struct hash<::nano::uint128_union>; template <> -struct hash<::nano::uint256_union> -{ - size_t operator() (::nano::uint256_union const & value) const noexcept - { - return std::hash<::nano::uint256_union> () (value); - } -}; +struct hash<::nano::uint256_union>; template <> -struct hash<::nano::public_key> -{ - size_t operator() (::nano::public_key const & value) const noexcept - { - return std::hash<::nano::public_key> () (value); - } -}; +struct hash<::nano::public_key>; template <> -struct hash<::nano::block_hash> -{ - size_t operator() (::nano::block_hash const & value) const noexcept - { - return std::hash<::nano::block_hash> () (value); - } -}; +struct hash<::nano::block_hash>; template <> -struct hash<::nano::hash_or_account> -{ - size_t operator() (::nano::hash_or_account const & value) const noexcept - { - return std::hash<::nano::hash_or_account> () (value); - } -}; +struct hash<::nano::hash_or_account>; template <> -struct hash<::nano::root> -{ - size_t operator() (::nano::root const & value) const noexcept - { - return std::hash<::nano::root> () (value); - } -}; +struct hash<::nano::root>; template <> -struct hash<::nano::link> -{ - size_t operator() (::nano::link const & value) const noexcept - { - return std::hash<::nano::link> () (value); - } -}; +struct hash<::nano::link>; template <> -struct hash<::nano::raw_key> -{ - size_t operator() (::nano::raw_key const & value) const noexcept - { - return std::hash<::nano::raw_key> () (value); - } -}; +struct hash<::nano::raw_key>; template <> -struct hash<::nano::wallet_id> -{ - size_t operator() (::nano::wallet_id const & value) const noexcept - { - return std::hash<::nano::wallet_id> () (value); - } -}; +struct hash<::nano::wallet_id>; template <> -struct hash<::nano::uint512_union> -{ - size_t operator() (::nano::uint512_union const & value) const noexcept - { - return std::hash<::nano::uint512_union> () (value); - } -}; +struct hash<::nano::uint512_union>; template <> -struct hash<::nano::qualified_root> -{ - size_t operator() (::nano::qualified_root const & value) const noexcept - { - return std::hash<::nano::qualified_root> () (value); - } -}; +struct hash<::nano::qualified_root>; } /* diff --git a/nano/lib/numbers_templ.hpp b/nano/lib/numbers_templ.hpp new file mode 100644 index 0000000000..d40de592a0 --- /dev/null +++ b/nano/lib/numbers_templ.hpp @@ -0,0 +1,189 @@ +#pragma once + +#include + +#include + +namespace std +{ +template <> +struct hash<::nano::uint128_union> +{ + size_t operator() (::nano::uint128_union const & value) const noexcept + { + return value.qwords[0] + value.qwords[1]; + } +}; +template <> +struct hash<::nano::uint256_union> +{ + size_t operator() (::nano::uint256_union const & value) const noexcept + { + return value.qwords[0] + value.qwords[1] + value.qwords[2] + value.qwords[3]; + } +}; +template <> +struct hash<::nano::public_key> +{ + size_t operator() (::nano::public_key const & value) const noexcept + { + return hash<::nano::uint256_union>{}(value); + } +}; +template <> +struct hash<::nano::block_hash> +{ + size_t operator() (::nano::block_hash const & value) const noexcept + { + return hash<::nano::uint256_union>{}(value); + } +}; +template <> +struct hash<::nano::hash_or_account> +{ + size_t operator() (::nano::hash_or_account const & value) const noexcept + { + return hash<::nano::block_hash>{}(value.as_block_hash ()); + } +}; +template <> +struct hash<::nano::root> +{ + size_t operator() (::nano::root const & value) const noexcept + { + return hash<::nano::hash_or_account>{}(value); + } +}; +template <> +struct hash<::nano::link> +{ + size_t operator() (::nano::link const & value) const noexcept + { + return hash<::nano::hash_or_account>{}(value); + } +}; +template <> +struct hash<::nano::raw_key> +{ + size_t operator() (::nano::raw_key const & value) const noexcept + { + return hash<::nano::uint256_union>{}(value); + } +}; +template <> +struct hash<::nano::wallet_id> +{ + size_t operator() (::nano::wallet_id const & value) const noexcept + { + return hash<::nano::uint256_union>{}(value); + } +}; +template <> +struct hash<::nano::uint512_union> +{ + size_t operator() (::nano::uint512_union const & value) const noexcept + { + return hash<::nano::uint256_union>{}(value.uint256s[0]) + hash<::nano::uint256_union> () (value.uint256s[1]); + } +}; +template <> +struct hash<::nano::qualified_root> +{ + size_t operator() (::nano::qualified_root const & value) const noexcept + { + return hash<::nano::uint512_union>{}(value); + } +}; +} + +namespace boost +{ +template <> +struct hash<::nano::uint128_union> +{ + size_t operator() (::nano::uint128_union const & value) const noexcept + { + return std::hash<::nano::uint128_union> () (value); + } +}; +template <> +struct hash<::nano::uint256_union> +{ + size_t operator() (::nano::uint256_union const & value) const noexcept + { + return std::hash<::nano::uint256_union> () (value); + } +}; +template <> +struct hash<::nano::public_key> +{ + size_t operator() (::nano::public_key const & value) const noexcept + { + return std::hash<::nano::public_key> () (value); + } +}; +template <> +struct hash<::nano::block_hash> +{ + size_t operator() (::nano::block_hash const & value) const noexcept + { + return std::hash<::nano::block_hash> () (value); + } +}; +template <> +struct hash<::nano::hash_or_account> +{ + size_t operator() (::nano::hash_or_account const & value) const noexcept + { + return std::hash<::nano::hash_or_account> () (value); + } +}; +template <> +struct hash<::nano::root> +{ + size_t operator() (::nano::root const & value) const noexcept + { + return std::hash<::nano::root> () (value); + } +}; +template <> +struct hash<::nano::link> +{ + size_t operator() (::nano::link const & value) const noexcept + { + return std::hash<::nano::link> () (value); + } +}; +template <> +struct hash<::nano::raw_key> +{ + size_t operator() (::nano::raw_key const & value) const noexcept + { + return std::hash<::nano::raw_key> () (value); + } +}; +template <> +struct hash<::nano::wallet_id> +{ + size_t operator() (::nano::wallet_id const & value) const noexcept + { + return std::hash<::nano::wallet_id> () (value); + } +}; +template <> +struct hash<::nano::uint512_union> +{ + size_t operator() (::nano::uint512_union const & value) const noexcept + { + return std::hash<::nano::uint512_union> () (value); + } +}; +template <> +struct hash<::nano::qualified_root> +{ + size_t operator() (::nano::qualified_root const & value) const noexcept + { + return std::hash<::nano::qualified_root> () (value); + } +}; +} diff --git a/nano/lib/optional_ptr.hpp b/nano/lib/optional_ptr.hpp index 8c5fdc2fe7..9939ebf30d 100644 --- a/nano/lib/optional_ptr.hpp +++ b/nano/lib/optional_ptr.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include #include diff --git a/nano/lib/rate_limiting.hpp b/nano/lib/rate_limiting.hpp index f672467872..65f7bc21b7 100644 --- a/nano/lib/rate_limiting.hpp +++ b/nano/lib/rate_limiting.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -73,4 +75,4 @@ class rate_limiter final nano::rate::token_bucket bucket; mutable nano::mutex mutex; }; -} \ No newline at end of file +} diff --git a/nano/lib/work.cpp b/nano/lib/work.cpp index 7ee17cd1f9..3097bc4125 100644 --- a/nano/lib/work.cpp +++ b/nano/lib/work.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ nano::work_pool::work_pool (nano::network_constants & network_constants, unsigne } for (auto i (0u); i < count; ++i) { - threads.emplace_back (nano::thread_attributes::get_default (), [this, i] () { + threads.emplace_back ([this, i] () { nano::thread_role::set (nano::thread_role::name::work); nano::work_thread_reprioritize (); loop (i); @@ -240,4 +241,4 @@ nano::container_info nano::work_pool::container_info () const info.put ("pending", pending); info.add ("work_observers", work_observers.container_info ()); return info; -} \ No newline at end of file +} diff --git a/nano/lib/work.hpp b/nano/lib/work.hpp index 1640648934..0336d10a09 100644 --- a/nano/lib/work.hpp +++ b/nano/lib/work.hpp @@ -8,10 +8,10 @@ #include #include -#include #include #include +#include namespace nano { @@ -54,7 +54,7 @@ class work_pool final nano::network_constants & network_constants; std::atomic ticket; bool done; - std::vector threads; + std::vector threads; std::list pending; mutable nano::mutex mutex{ mutex_identifier (mutexes::work_pool) }; nano::condition_variable producer_condition; diff --git a/nano/lib/work_version.hpp b/nano/lib/work_version.hpp new file mode 100644 index 0000000000..fb24b82d32 --- /dev/null +++ b/nano/lib/work_version.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace nano +{ +enum class work_version +{ + unspecified, + work_1 +}; +} diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 37c2786bf2..5477769e7d 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -15,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index fc87e502f6..ed081e3724 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -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,9 +74,13 @@ 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 + fwd.hpp ipc/action_handler.hpp ipc/action_handler.cpp ipc/flatbuffers_handler.hpp @@ -165,6 +167,7 @@ add_library( transport/tcp_channel.cpp transport/fake.hpp transport/fake.cpp + transport/fwd.hpp transport/inproc.hpp transport/inproc.cpp transport/message_deserializer.hpp diff --git a/nano/node/active_elections.cpp b/nano/node/active_elections.cpp index 4d8c953f56..758752a08e 100644 --- a/nano/node/active_elections.cpp +++ b/nano/node/active_elections.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -624,4 +625,4 @@ nano::stat::type nano::to_stat_type (nano::election_state state) nano::stat::detail nano::to_stat_detail (nano::election_status_type type) { return nano::enum_util::cast (type); -} \ No newline at end of file +} diff --git a/nano/node/bandwidth_limiter.hpp b/nano/node/bandwidth_limiter.hpp index 1bd9e58339..7afafee75c 100644 --- a/nano/node/bandwidth_limiter.hpp +++ b/nano/node/bandwidth_limiter.hpp @@ -50,4 +50,4 @@ class bandwidth_limiter final nano::rate_limiter limiter_generic; nano::rate_limiter limiter_bootstrap; }; -} \ No newline at end of file +} diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 34d6956a8b..7f47f79d00 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -518,4 +519,4 @@ std::string_view nano::to_string (nano::block_source source) nano::stat::detail nano::to_stat_detail (nano::block_source type) { return nano::enum_util::cast (type); -} \ No newline at end of file +} diff --git a/nano/node/bootstrap/bootstrap.cpp b/nano/node/bootstrap/bootstrap.cpp index 8779400eec..fe021ffd27 100644 --- a/nano/node/bootstrap/bootstrap.cpp +++ b/nano/node/bootstrap/bootstrap.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/nano/node/bootstrap/bootstrap.hpp b/nano/node/bootstrap/bootstrap.hpp index f06f83196b..3d6ec25f12 100644 --- a/nano/node/bootstrap/bootstrap.hpp +++ b/nano/node/bootstrap/bootstrap.hpp @@ -1,7 +1,8 @@ #pragma once +#include #include -#include +#include #include #include diff --git a/nano/node/bootstrap/bootstrap_attempt.hpp b/nano/node/bootstrap/bootstrap_attempt.hpp index ea64fe9fd0..ce6c686ef8 100644 --- a/nano/node/bootstrap/bootstrap_attempt.hpp +++ b/nano/node/bootstrap/bootstrap_attempt.hpp @@ -2,6 +2,8 @@ #include +#include + #include #include diff --git a/nano/node/bootstrap/bootstrap_bulk_push.cpp b/nano/node/bootstrap/bootstrap_bulk_push.cpp index c023ec1fe5..5d101fab48 100644 --- a/nano/node/bootstrap/bootstrap_bulk_push.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_push.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/nano/node/bootstrap/bootstrap_bulk_push.hpp b/nano/node/bootstrap/bootstrap_bulk_push.hpp index d40e0fe5a4..19f8db7646 100644 --- a/nano/node/bootstrap/bootstrap_bulk_push.hpp +++ b/nano/node/bootstrap/bootstrap_bulk_push.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/nano/node/bootstrap/bootstrap_connections.cpp b/nano/node/bootstrap/bootstrap_connections.cpp index b3f1334b8f..62e7bc07bf 100644 --- a/nano/node/bootstrap/bootstrap_connections.cpp +++ b/nano/node/bootstrap/bootstrap_connections.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include diff --git a/nano/node/bootstrap/bootstrap_connections.hpp b/nano/node/bootstrap/bootstrap_connections.hpp index d246c23bb7..ee86e32a5c 100644 --- a/nano/node/bootstrap/bootstrap_connections.hpp +++ b/nano/node/bootstrap/bootstrap_connections.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/nano/node/bootstrap/bootstrap_lazy.cpp b/nano/node/bootstrap/bootstrap_lazy.cpp index 439aa0ced0..79bbce58a8 100644 --- a/nano/node/bootstrap/bootstrap_lazy.cpp +++ b/nano/node/bootstrap/bootstrap_lazy.cpp @@ -1,7 +1,8 @@ +#include #include #include #include -#include +#include #include #include #include diff --git a/nano/node/bootstrap_ascending/account_sets.cpp b/nano/node/bootstrap_ascending/account_sets.cpp index 4d0a276dfc..692ac43fd7 100644 --- a/nano/node/bootstrap_ascending/account_sets.cpp +++ b/nano/node/bootstrap_ascending/account_sets.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include #include @@ -354,4 +356,4 @@ nano::container_info nano::bootstrap_ascending::account_sets::container_info () info.put ("blocking", blocking); info.put ("blocking_unknown", blocking_unknown); return info; -} \ No newline at end of file +} diff --git a/nano/node/bootstrap_ascending/account_sets.hpp b/nano/node/bootstrap_ascending/account_sets.hpp index d83d3a8898..22d35e6060 100644 --- a/nano/node/bootstrap_ascending/account_sets.hpp +++ b/nano/node/bootstrap_ascending/account_sets.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -18,8 +19,6 @@ namespace mi = boost::multi_index; namespace nano { -class stats; - namespace bootstrap_ascending { /** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */ @@ -161,4 +160,4 @@ namespace bootstrap_ascending info_t info () const; }; } -} \ No newline at end of file +} diff --git a/nano/node/bootstrap_ascending/service.cpp b/nano/node/bootstrap_ascending/service.cpp index bb6f4183e1..107c9d0344 100644 --- a/nano/node/bootstrap_ascending/service.cpp +++ b/nano/node/bootstrap_ascending/service.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -852,4 +853,4 @@ nano::container_info nano::bootstrap_ascending::service::container_info () const nano::stat::detail nano::bootstrap_ascending::to_stat_detail (nano::bootstrap_ascending::service::query_type type) { return nano::enum_util::cast (type); -} \ No newline at end of file +} diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index 5ebe67bbf1..fd65b4e3a3 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -2,8 +2,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/nano/node/confirming_set.cpp b/nano/node/confirming_set.cpp index 2921881b52..3de7e7dc8d 100644 --- a/nano/node/confirming_set.cpp +++ b/nano/node/confirming_set.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/nano/node/confirming_set.hpp b/nano/node/confirming_set.hpp index 644b241c92..50ca656552 100644 --- a/nano/node/confirming_set.hpp +++ b/nano/node/confirming_set.hpp @@ -1,10 +1,12 @@ #pragma once #include +#include #include #include #include #include +#include #include #include diff --git a/nano/node/distributed_work.cpp b/nano/node/distributed_work.cpp index 81d771a5e1..a7cb40598e 100644 --- a/nano/node/distributed_work.cpp +++ b/nano/node/distributed_work.cpp @@ -5,6 +5,7 @@ #include #include +#include std::shared_ptr nano::distributed_work::peer_request::get_prepared_json_request (std::string const & request_string_a) const { diff --git a/nano/node/distributed_work.hpp b/nano/node/distributed_work.hpp index 17edecc60b..4d83e0160a 100644 --- a/nano/node/distributed_work.hpp +++ b/nano/node/distributed_work.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include diff --git a/nano/node/distributed_work_factory.hpp b/nano/node/distributed_work_factory.hpp index 8024bb1841..56daf3b853 100644 --- a/nano/node/distributed_work_factory.hpp +++ b/nano/node/distributed_work_factory.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/nano/node/election.cpp b/nano/node/election.cpp index 06ea41350d..7cd964aae6 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -9,6 +9,7 @@ #include #include #include +#include using namespace std::chrono; diff --git a/nano/node/election.hpp b/nano/node/election.hpp index 3ab73a765f..718cbf680c 100644 --- a/nano/node/election.hpp +++ b/nano/node/election.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include diff --git a/nano/node/common.cpp b/nano/node/endpoint.cpp similarity index 93% rename from nano/node/common.cpp rename to nano/node/endpoint.cpp index 5edab1f7f9..891f887282 100644 --- a/nano/node/common.cpp +++ b/nano/node/endpoint.cpp @@ -2,10 +2,11 @@ #include #include #include -#include #include +#include #include #include +#include #include @@ -27,6 +28,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; diff --git a/nano/node/common.hpp b/nano/node/endpoint.hpp similarity index 53% rename from nano/node/common.hpp rename to nano/node/endpoint.hpp index 5dd98516df..c1ed629ef3 100644 --- a/nano/node/common.hpp +++ b/nano/node/endpoint.hpp @@ -1,13 +1,15 @@ #pragma once -#include -#include -#include -#include #include -#include +#include #include +#include + +namespace boost::asio::ip +{ +class address; +} namespace nano { @@ -18,16 +20,11 @@ bool parse_endpoint (std::string const &, nano::endpoint &); std::optional 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 struct endpoint_hash { @@ -38,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); } }; @@ -47,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 (big) ^ static_cast (big >> 32)); return result; } @@ -82,60 +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 ehash; - return ehash (endpoint_a); - } -}; +struct hash<::nano::endpoint>; #ifndef BOOST_ASIO_HAS_STD_HASH template <> -struct hash -{ - std::size_t operator() (boost::asio::ip::address const & ip_a) const - { - ip_address_hash ihash; - return ihash (ip_a); - } -}; +struct hash; #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 -{ - std::size_t operator() (boost::asio::ip::address const & ip_a) const - { - std::hash hash; - return hash (ip_a); - } -}; -} - -namespace nano -{ -/** Helper guard which contains all the necessary purge (remove all memory even if used) functions */ -class node_singleton_memory_pool_purge_guard -{ -public: - node_singleton_memory_pool_purge_guard (); - -private: - nano::cleanup_guard cleanup_guard; -}; +struct hash; } diff --git a/nano/node/endpoint_templ.hpp b/nano/node/endpoint_templ.hpp new file mode 100644 index 0000000000..22d17e9630 --- /dev/null +++ b/nano/node/endpoint_templ.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include + +namespace std +{ +template <> +struct hash<::nano::endpoint> +{ + std::size_t operator() (::nano::endpoint const & endpoint_a) const + { + endpoint_hash ehash; + return ehash (endpoint_a); + } +}; + +#ifndef BOOST_ASIO_HAS_STD_HASH +template <> +struct hash +{ + std::size_t operator() (boost::asio::ip::address const & ip_a) const + { + ip_address_hash 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 +{ + std::size_t operator() (boost::asio::ip::address const & ip_a) const + { + std::hash hash; + return hash (ip_a); + } +}; +} diff --git a/nano/node/epoch_upgrader.cpp b/nano/node/epoch_upgrader.cpp index 69d2a50657..1a44e9f244 100644 --- a/nano/node/epoch_upgrader.cpp +++ b/nano/node/epoch_upgrader.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/nano/node/epoch_upgrader.hpp b/nano/node/epoch_upgrader.hpp index d9bccad98e..5cbb9b7b88 100644 --- a/nano/node/epoch_upgrader.hpp +++ b/nano/node/epoch_upgrader.hpp @@ -1,22 +1,18 @@ #pragma once -#include +#include #include #include #include +#include +#include +#include +#include #include namespace nano { -class node; -class ledger; -namespace store -{ - class component; -} -class network_params; - class epoch_upgrader final { public: diff --git a/nano/node/fwd.hpp b/nano/node/fwd.hpp index 7bdcb57665..df857acfc1 100644 --- a/nano/node/fwd.hpp +++ b/nano/node/fwd.hpp @@ -1,24 +1,17 @@ #pragma once +#include #include #include #include -// 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; @@ -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; @@ -53,4 +48,4 @@ class hinted; class manual; class optimistic; class priority; -} \ No newline at end of file +} diff --git a/nano/node/ipc/flatbuffers_util.cpp b/nano/node/ipc/flatbuffers_util.cpp index f8265733fe..c4d3a0355f 100644 --- a/nano/node/ipc/flatbuffers_util.cpp +++ b/nano/node/ipc/flatbuffers_util.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/nano/node/ipc/ipc_config.cpp b/nano/node/ipc/ipc_config.cpp index 04d4901b3e..323063976d 100644 --- a/nano/node/ipc/ipc_config.cpp +++ b/nano/node/ipc/ipc_config.cpp @@ -2,6 +2,12 @@ #include #include +nano::ipc::ipc_config_tcp_socket::ipc_config_tcp_socket (nano::network_constants & network_constants) : + network_constants{ network_constants }, + port{ network_constants.default_ipc_port } +{ +} + nano::error nano::ipc::ipc_config::serialize_toml (nano::tomlconfig & toml) const { nano::tomlconfig tcp_l; diff --git a/nano/node/ipc/ipc_config.hpp b/nano/node/ipc/ipc_config.hpp index 4722177da8..3cdb73bef3 100644 --- a/nano/node/ipc/ipc_config.hpp +++ b/nano/node/ipc/ipc_config.hpp @@ -2,12 +2,12 @@ #include #include +#include #include namespace nano { -class tomlconfig; namespace ipc { /** Base class for transport configurations */ @@ -46,11 +46,7 @@ namespace ipc class ipc_config_tcp_socket : public ipc_config_transport { public: - ipc_config_tcp_socket (nano::network_constants & network_constants) : - network_constants{ network_constants }, - port{ network_constants.default_ipc_port } - { - } + ipc_config_tcp_socket (nano::network_constants & network_constants); nano::network_constants & network_constants; /** Listening port */ uint16_t port; diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 288296d052..08f911108f 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -1,14 +1,17 @@ +#include #include #include #include +#include #include #include +#include #include #include #include -#include #include #include +#include #include #include #include diff --git a/nano/node/local_block_broadcaster.cpp b/nano/node/local_block_broadcaster.cpp index ad1a2201fe..f136bd036c 100644 --- a/nano/node/local_block_broadcaster.cpp +++ b/nano/node/local_block_broadcaster.cpp @@ -8,6 +8,8 @@ #include #include +#include + nano::local_block_broadcaster::local_block_broadcaster (local_block_broadcaster_config const & config_a, nano::node & node_a, nano::block_processor & block_processor_a, nano::network & network_a, nano::confirming_set & confirming_set_a, nano::stats & stats_a, nano::logger & logger_a, bool enabled_a) : config{ config_a }, node{ node_a }, @@ -230,4 +232,4 @@ nano::container_info nano::local_block_broadcaster::container_info () const nano::container_info info; info.put ("local", local_blocks); return info; -} \ No newline at end of file +} diff --git a/nano/node/local_block_broadcaster.hpp b/nano/node/local_block_broadcaster.hpp index d2bed33ce3..a88ed25f95 100644 --- a/nano/node/local_block_broadcaster.hpp +++ b/nano/node/local_block_broadcaster.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/nano/node/local_vote_history.hpp b/nano/node/local_vote_history.hpp index 311867e21a..9ee4e38c64 100644 --- a/nano/node/local_vote_history.hpp +++ b/nano/node/local_vote_history.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/nano/node/message_processor.cpp b/nano/node/message_processor.cpp index 469c55bd18..a172f48df9 100644 --- a/nano/node/message_processor.cpp +++ b/nano/node/message_processor.cpp @@ -3,6 +3,7 @@ #include #include #include +#include nano::message_processor::message_processor (message_processor_config const & config_a, nano::node & node_a) : config{ config_a }, @@ -317,4 +318,4 @@ nano::error nano::message_processor_config::deserialize (nano::tomlconfig & toml toml.get ("max_queue", max_queue); return toml.get_error (); -} \ No newline at end of file +} diff --git a/nano/node/messages.cpp b/nano/node/messages.cpp index a2e819cc37..d665ee3f86 100644 --- a/nano/node/messages.cpp +++ b/nano/node/messages.cpp @@ -1,15 +1,18 @@ +#include #include #include #include +#include #include #include #include #include #include -#include #include +#include #include #include +#include #include #include @@ -1873,7 +1876,7 @@ void nano::asc_pull_ack::blocks_payload::serialize (nano::stream & stream) const nano::serialize_block (stream, *block); } // For convenience, end with null block terminator - nano::serialize_block_type (stream, nano::block_type::not_a_block); + nano::write (stream, nano::block_type::not_a_block); } void nano::asc_pull_ack::blocks_payload::deserialize (nano::stream & stream) diff --git a/nano/node/messages.hpp b/nano/node/messages.hpp index 00f1070b0e..8e1db8e8eb 100644 --- a/nano/node/messages.hpp +++ b/nano/node/messages.hpp @@ -1,19 +1,19 @@ #pragma once +#include #include -#include #include #include -#include +#include #include #include #include #include #include #include -#include -#include +#include #include +#include #include #include @@ -22,6 +22,12 @@ #include #include +namespace nano +{ +using block_uniquer = uniquer; +using vote_uniquer = uniquer; +} + namespace nano { /** diff --git a/nano/node/network.hpp b/nano/node/network.hpp index 0ab498ed2b..d1130271d1 100644 --- a/nano/node/network.hpp +++ b/nano/node/network.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/nano/node/node.cpp b/nano/node/node.cpp index e556fda038..0c55b6e114 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1,19 +1,21 @@ +#include #include #include #include #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include +#include #include #include #include @@ -37,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/online_reps.hpp b/nano/node/online_reps.hpp index 2838346f3b..d8e60665de 100644 --- a/nano/node/online_reps.hpp +++ b/nano/node/online_reps.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/nano/node/peer_exclusion.hpp b/nano/node/peer_exclusion.hpp index 3100bfe09c..e209d5e638 100644 --- a/nano/node/peer_exclusion.hpp +++ b/nano/node/peer_exclusion.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include #include #include diff --git a/nano/node/peer_history.hpp b/nano/node/peer_history.hpp index 15d13ffdde..6200446b57 100644 --- a/nano/node/peer_history.hpp +++ b/nano/node/peer_history.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -54,4 +54,4 @@ class peer_history final nano::condition_variable condition; std::thread thread; }; -} \ No newline at end of file +} diff --git a/nano/node/portmapping.hpp b/nano/node/portmapping.hpp index cc542896ad..437852e945 100644 --- a/nano/node/portmapping.hpp +++ b/nano/node/portmapping.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/nano/node/recently_confirmed_cache.hpp b/nano/node/recently_confirmed_cache.hpp index 803039275e..bdfc95611a 100644 --- a/nano/node/recently_confirmed_cache.hpp +++ b/nano/node/recently_confirmed_cache.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/nano/node/rep_tiers.cpp b/nano/node/rep_tiers.cpp index 6bc532787e..a0eb4fe433 100644 --- a/nano/node/rep_tiers.cpp +++ b/nano/node/rep_tiers.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -149,4 +150,4 @@ nano::container_info nano::rep_tiers::container_info () const nano::stat::detail nano::to_stat_detail (nano::rep_tier tier) { return nano::enum_util::cast (tier); -} \ No newline at end of file +} diff --git a/nano/node/rep_tiers.hpp b/nano/node/rep_tiers.hpp index 71c63ab0df..3c4b54ee11 100644 --- a/nano/node/rep_tiers.hpp +++ b/nano/node/rep_tiers.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -64,4 +65,4 @@ class rep_tiers final mutable nano::mutex mutex; std::thread thread; }; -} \ No newline at end of file +} diff --git a/nano/node/repcrawler.cpp b/nano/node/repcrawler.cpp index b3dc58c405..b54eae4a50 100644 --- a/nano/node/repcrawler.cpp +++ b/nano/node/repcrawler.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include diff --git a/nano/node/repcrawler.hpp b/nano/node/repcrawler.hpp index c7892399e1..cd9d680096 100644 --- a/nano/node/repcrawler.hpp +++ b/nano/node/repcrawler.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/request_aggregator.cpp b/nano/node/request_aggregator.cpp index 8465b7d2b0..75faab069d 100644 --- a/nano/node/request_aggregator.cpp +++ b/nano/node/request_aggregator.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include diff --git a/nano/node/scheduler/bucket.hpp b/nano/node/scheduler/bucket.hpp index 668bbec6d6..a95878dabf 100644 --- a/nano/node/scheduler/bucket.hpp +++ b/nano/node/scheduler/bucket.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include +#include #include #include diff --git a/nano/node/telemetry.hpp b/nano/node/telemetry.hpp index cb9c337a91..8e0fe8c314 100644 --- a/nano/node/telemetry.hpp +++ b/nano/node/telemetry.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/nano/node/transport/channel.cpp b/nano/node/transport/channel.cpp index 6a4c6663e8..8b7055c46a 100644 --- a/nano/node/transport/channel.cpp +++ b/nano/node/transport/channel.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/nano/node/transport/channel.hpp b/nano/node/transport/channel.hpp index 212dc1c373..8f860f58c3 100644 --- a/nano/node/transport/channel.hpp +++ b/nano/node/transport/channel.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -140,4 +140,4 @@ class channel public: // Logging virtual void operator() (nano::object_stream &) const; }; -} \ No newline at end of file +} diff --git a/nano/node/transport/fwd.hpp b/nano/node/transport/fwd.hpp index c62c470304..4be374eba9 100644 --- a/nano/node/transport/fwd.hpp +++ b/nano/node/transport/fwd.hpp @@ -7,4 +7,8 @@ class tcp_channel; class tcp_channels; class tcp_server; class tcp_socket; -} \ No newline at end of file +} +namespace nano::transport::fake +{ +class channel; +} diff --git a/nano/node/transport/message_deserializer.hpp b/nano/node/transport/message_deserializer.hpp index 4c4d62c229..ca8d923f37 100644 --- a/nano/node/transport/message_deserializer.hpp +++ b/nano/node/transport/message_deserializer.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/nano/node/transport/tcp_channels.hpp b/nano/node/transport/tcp_channels.hpp index 1b6f1e363d..8e1aeeccc0 100644 --- a/nano/node/transport/tcp_channels.hpp +++ b/nano/node/transport/tcp_channels.hpp @@ -1,7 +1,8 @@ #pragma once +#include #include -#include +#include #include #include #include @@ -170,4 +171,4 @@ class tcp_channels final mutable nano::random_generator rng; }; -} \ No newline at end of file +} diff --git a/nano/node/transport/tcp_listener.hpp b/nano/node/transport/tcp_listener.hpp index 55c63da64a..66644665d1 100644 --- a/nano/node/transport/tcp_listener.hpp +++ b/nano/node/transport/tcp_listener.hpp @@ -1,7 +1,8 @@ #pragma once #include -#include +#include +#include #include #include @@ -176,4 +177,4 @@ class tcp_listener final static std::string_view to_string (connection_type); static nano::transport::socket_endpoint to_socket_endpoint (connection_type); }; -} \ No newline at end of file +} diff --git a/nano/node/transport/tcp_server.hpp b/nano/node/transport/tcp_server.hpp index 96085ae8b1..c4971464d7 100644 --- a/nano/node/transport/tcp_server.hpp +++ b/nano/node/transport/tcp_server.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/nano/node/transport/transport.cpp b/nano/node/transport/transport.cpp index 4a90626f9e..21f5fea047 100644 --- a/nano/node/transport/transport.cpp +++ b/nano/node/transport/transport.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -164,4 +164,4 @@ bool nano::transport::reserved_address (nano::endpoint const & endpoint_a, bool } } return result; -} \ No newline at end of file +} diff --git a/nano/node/transport/transport.hpp b/nano/node/transport/transport.hpp index 3065bbd049..5703a8c73d 100644 --- a/nano/node/transport/transport.hpp +++ b/nano/node/transport/transport.hpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -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); -} \ No newline at end of file +} diff --git a/nano/node/vote_cache.cpp b/nano/node/vote_cache.cpp index 36f9c4adf9..4fedd3a04c 100644 --- a/nano/node/vote_cache.cpp +++ b/nano/node/vote_cache.cpp @@ -1,8 +1,10 @@ +#include #include #include #include #include #include +#include #include diff --git a/nano/node/vote_cache.hpp b/nano/node/vote_cache.hpp index c70bae9d37..b371941ac7 100644 --- a/nano/node/vote_cache.hpp +++ b/nano/node/vote_cache.hpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include #include #include @@ -13,6 +15,7 @@ #include #include +#include #include #include #include @@ -21,16 +24,6 @@ namespace mi = boost::multi_index; -namespace nano -{ -class node; -class active_elections; -class election; -class vote; -enum class vote_code; -enum class vote_source; -} - namespace nano { class vote_cache_config final diff --git a/nano/node/vote_generator.cpp b/nano/node/vote_generator.cpp index e29c88cc97..faf3c273ba 100644 --- a/nano/node/vote_generator.cpp +++ b/nano/node/vote_generator.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -326,4 +327,4 @@ nano::container_info nano::vote_generator::container_info () const info.put ("requests", requests.size ()); info.add ("queue", vote_generation_queue.container_info ()); return info; -} \ No newline at end of file +} diff --git a/nano/node/vote_processor.cpp b/nano/node/vote_processor.cpp index 4d0c8ef547..283e78ac90 100644 --- a/nano/node/vote_processor.cpp +++ b/nano/node/vote_processor.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -376,4 +377,4 @@ nano::error nano::vote_processor_config::deserialize (nano::tomlconfig & toml) toml.get ("batch_size", batch_size); return toml.get_error (); -} \ No newline at end of file +} diff --git a/nano/node/vote_router.cpp b/nano/node/vote_router.cpp index acf3d069c3..0f80e4995a 100644 --- a/nano/node/vote_router.cpp +++ b/nano/node/vote_router.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -192,4 +193,4 @@ nano::container_info nano::vote_router::container_info () const nano::container_info info; info.put ("elections", elections); return info; -} \ No newline at end of file +} diff --git a/nano/node/vote_router.hpp b/nano/node/vote_router.hpp index ed2d3d09c5..37c6ef87c0 100644 --- a/nano/node/vote_router.hpp +++ b/nano/node/vote_router.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/nano/node/vote_spacing.hpp b/nano/node/vote_spacing.hpp index f46cd6352a..c5ee41827f 100644 --- a/nano/node/vote_spacing.hpp +++ b/nano/node/vote_spacing.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/nano/node/wallet.cpp b/nano/node/wallet.cpp index 18dd7df7a8..ba65fe0dc5 100644 --- a/nano/node/wallet.cpp +++ b/nano/node/wallet.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/node/websocket.cpp b/nano/node/websocket.cpp index d2b8eab72d..32a68d2bb5 100644 --- a/nano/node/websocket.cpp +++ b/nano/node/websocket.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -11,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/websocket.hpp b/nano/node/websocket.hpp index 2a38956060..1a5eb0dbb8 100644 --- a/nano/node/websocket.hpp +++ b/nano/node/websocket.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/nano/qt_test/entry.cpp b/nano/qt_test/entry.cpp index b3ce57fd8f..1847ff850d 100644 --- a/nano/qt_test/entry.cpp +++ b/nano/qt_test/entry.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/nano/qt_test/qt.cpp b/nano/qt_test/qt.cpp index b4070ca80e..f79f35e7c1 100644 --- a/nano/qt_test/qt.cpp +++ b/nano/qt_test/qt.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/nano/rpc_test/entry.cpp b/nano/rpc_test/entry.cpp index 806f07645b..e16a3f4e5f 100644 --- a/nano/rpc_test/entry.cpp +++ b/nano/rpc_test/entry.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index ce050df029..de71a49c8c 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -1,9 +1,12 @@ #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -22,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/secure/CMakeLists.txt b/nano/secure/CMakeLists.txt index c495c12700..a0cbea2a44 100644 --- a/nano/secure/CMakeLists.txt +++ b/nano/secure/CMakeLists.txt @@ -20,6 +20,7 @@ add_library( account_iterator_impl.hpp common.hpp common.cpp + fwd.hpp generate_cache_flags.hpp generate_cache_flags.cpp ledger.hpp diff --git a/nano/secure/account_info.cpp b/nano/secure/account_info.cpp index 1b18ca6024..81bcec0c6b 100644 --- a/nano/secure/account_info.cpp +++ b/nano/secure/account_info.cpp @@ -1,3 +1,4 @@ +#include #include nano::account_info::account_info (nano::block_hash const & head_a, nano::account const & representative_a, nano::block_hash const & open_block_a, nano::amount const & balance_a, nano::seconds_t modified_a, uint64_t block_count_a, nano::epoch epoch_a) : @@ -90,4 +91,4 @@ bool nano::account_info_v22::deserialize (nano::stream & stream_a) } return error; -} \ No newline at end of file +} diff --git a/nano/secure/account_info.hpp b/nano/secure/account_info.hpp index ee850d8d2f..a40136f64f 100644 --- a/nano/secure/account_info.hpp +++ b/nano/secure/account_info.hpp @@ -1,8 +1,8 @@ #pragma once #include +#include #include -#include #include namespace nano diff --git a/nano/secure/account_iterator_impl.hpp b/nano/secure/account_iterator_impl.hpp index a68f70b352..af8d0a7a19 100644 --- a/nano/secure/account_iterator_impl.hpp +++ b/nano/secure/account_iterator_impl.hpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index f5fd8e44fc..92abdf01d4 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -1,9 +1,12 @@ +#include #include #include #include #include #include #include +#include +#include #include #include #include diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index e1639bd265..b8f8ee1108 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -4,19 +4,12 @@ #include #include #include -#include +#include +#include #include #include -#include #include #include -#include -#include - -#include -#include -#include -#include #include #include diff --git a/nano/secure/fwd.hpp b/nano/secure/fwd.hpp index 1d57ae0cfc..f6bb2076a3 100644 --- a/nano/secure/fwd.hpp +++ b/nano/secure/fwd.hpp @@ -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; -} \ No newline at end of file diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index d2857974de..4533eddccd 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/nano/secure/pending_info.cpp b/nano/secure/pending_info.cpp index a9d52588a6..85a32a8aaa 100644 --- a/nano/secure/pending_info.cpp +++ b/nano/secure/pending_info.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/nano/secure/pending_info.hpp b/nano/secure/pending_info.hpp index c00e1cdb39..43273cab8f 100644 --- a/nano/secure/pending_info.hpp +++ b/nano/secure/pending_info.hpp @@ -1,18 +1,10 @@ #pragma once #include +#include #include -#include - -namespace nano -{ -class ledger; -} - -namespace nano::secure -{ -class transaction; -} +#include +#include namespace nano { diff --git a/nano/secure/receivable_iterator_impl.hpp b/nano/secure/receivable_iterator_impl.hpp index b2cbebef72..f2e1867dfa 100644 --- a/nano/secure/receivable_iterator_impl.hpp +++ b/nano/secure/receivable_iterator_impl.hpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/nano/secure/rep_weights.hpp b/nano/secure/rep_weights.hpp index 9209bbf255..29a2c28044 100644 --- a/nano/secure/rep_weights.hpp +++ b/nano/secure/rep_weights.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/nano/secure/vote.cpp b/nano/secure/vote.cpp index 296886634b..b7b7e6c633 100644 --- a/nano/secure/vote.cpp +++ b/nano/secure/vote.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -193,4 +194,4 @@ void nano::vote::operator() (nano::object_stream & obs) const obs.write ("final", is_final_timestamp (timestamp_m)); obs.write ("timestamp", timestamp_m); obs.write_range ("hashes", hashes); -} \ No newline at end of file +} diff --git a/nano/secure/vote.hpp b/nano/secure/vote.hpp index 0737acf00e..c4e24f149d 100644 --- a/nano/secure/vote.hpp +++ b/nano/secure/vote.hpp @@ -1,7 +1,7 @@ #pragma once +#include #include -#include #include #include @@ -10,11 +10,6 @@ #include -namespace nano -{ -class object_stream; -} - namespace nano { class vote final diff --git a/nano/slow_test/entry.cpp b/nano/slow_test/entry.cpp index 096c7dc6a9..83d12130de 100644 --- a/nano/slow_test/entry.cpp +++ b/nano/slow_test/entry.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index b9c3731f69..982c5b873e 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/slow_test/vote_processor.cpp b/nano/slow_test/vote_processor.cpp index 938aa2566a..b3fcffa9f7 100644 --- a/nano/slow_test/vote_processor.cpp +++ b/nano/slow_test/vote_processor.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/nano/store/CMakeLists.txt b/nano/store/CMakeLists.txt index 0fb509489a..e3f4ef175a 100644 --- a/nano/store/CMakeLists.txt +++ b/nano/store/CMakeLists.txt @@ -9,6 +9,7 @@ add_library( db_val_impl.hpp iterator.hpp final_vote.hpp + fwd.hpp lmdb/account.hpp lmdb/block.hpp lmdb/confirmation_height.hpp diff --git a/nano/store/component.hpp b/nano/store/component.hpp index f36f837efe..13f00910f5 100644 --- a/nano/store/component.hpp +++ b/nano/store/component.hpp @@ -2,8 +2,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -11,26 +12,12 @@ #include #include +#include #include namespace nano { -namespace store -{ - class account; - class block; - class confirmation_height; - class final_vote; - class online_weight; - class peer; - class pending; - class pruned; - class version; - class rep_weight; -} -class ledger_cache; - namespace store { /** @@ -90,8 +77,8 @@ namespace store virtual void rebuild_db (write_transaction const & transaction_a) = 0; /** Not applicable to all sub-classes */ - virtual void serialize_mdb_tracker (boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds){}; - virtual void serialize_memory_stats (boost::property_tree::ptree &) = 0; + virtual void serialize_mdb_tracker (::boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds){}; + virtual void serialize_memory_stats (::boost::property_tree::ptree &) = 0; virtual bool init_error () const = 0; diff --git a/nano/store/db_val.hpp b/nano/store/db_val.hpp index 7cc415a5fd..12b81a143f 100644 --- a/nano/store/db_val.hpp +++ b/nano/store/db_val.hpp @@ -16,6 +16,7 @@ class account_info_v22; class block; class pending_info; class pending_key; +class vote; } namespace nano::store diff --git a/nano/store/fwd.hpp b/nano/store/fwd.hpp index 9ecd1ff3a5..febe31a892 100644 --- a/nano/store/fwd.hpp +++ b/nano/store/fwd.hpp @@ -1,9 +1,23 @@ #pragma once +namespace nano +{ +enum class tables; +} namespace nano::store { +class account; +class block; class component; +class confirmation_height; +class final_vote; +class online_weight; +class peer; +class pending; +class pruned; +class read_transaction; +class rep_weight; class transaction; +class version; class write_transaction; -class read_transaction; -} \ No newline at end of file +} diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index fe6026fdfb..75f3e51497 100644 --- a/nano/store/rocksdb/rocksdb.cpp +++ b/nano/store/rocksdb/rocksdb.cpp @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/nano/test_common/network.hpp b/nano/test_common/network.hpp index 3bfcd22c38..d201fee17d 100644 --- a/nano/test_common/network.hpp +++ b/nano/test_common/network.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace nano diff --git a/nano/test_common/system.cpp b/nano/test_common/system.cpp index 758a5c72ee..4071ea4624 100644 --- a/nano/test_common/system.cpp +++ b/nano/test_common/system.cpp @@ -1,8 +1,9 @@ #include #include #include +#include #include -#include +#include #include #include #include diff --git a/nano/test_common/telemetry.cpp b/nano/test_common/telemetry.cpp index db2465e074..a2aa36a3ce 100644 --- a/nano/test_common/telemetry.cpp +++ b/nano/test_common/telemetry.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -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; -} \ No newline at end of file +} diff --git a/nano/test_common/testutil.cpp b/nano/test_common/testutil.cpp index f2c3c77129..8218fd22c4 100644 --- a/nano/test_common/testutil.cpp +++ b/nano/test_common/testutil.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/test_common/testutil.hpp b/nano/test_common/testutil.hpp index 716be359cf..017d616550 100644 --- a/nano/test_common/testutil.hpp +++ b/nano/test_common/testutil.hpp @@ -2,9 +2,9 @@ #include #include -#include -#include +#include #include +#include #include