diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b93fac65..4da28f153 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 338b6ec53..32d2a8964 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 f5dd614b3..fe90835fe 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 491741708..1b085c394 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 659ecd46b..45e493807 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 43c193815..f9469f3bf 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 2e65afacb..77fbc418d 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 6eb843746..f5e040aa9 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 9d08284dd..7c51ce85b 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 50fd6c8fc..83366b1ce 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 bff40fee2..0e9e80f90 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 0dd6e786d..d43d41269 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 6d5dd4ae9..087f84894 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 60d233821..12ff989af 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 44e9fa06d..7d65d6528 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 7d95fcf35..916c8dbf4 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 788d7c271..8765b1118 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 1ad2cee93..d441b626f 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 @@ -3692,4 +3694,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 a30b2eb10..ec8bed3f4 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 1d52769df..e9d0ba8d4 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 2f85074e4..5e99210c2 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 7f9f1088a..0ac3c28a3 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 2d120fe26..859d3ffb3 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 8b298dea1..4e237b34a 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 3389a8a96..55d63259f 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 e9e170f6d..79068966e 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 da16b4160..b090358e7 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 63eae4cf7..cb4eed460 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 76d53944f..748df5439 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 e69de29bb..8b37f71db 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 871f9bfcf..09dcc8a96 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 70ec28b40..5be00af00 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 020722e31..591c79999 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 d39bb3afc..4a0c7076b 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 4fc527eb0..d61233e4a 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 2312855cb..14524e556 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 bd1f30994..1e54097d0 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 4dda3dcf1..41b73e510 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 c67095967..239f5ad8c 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 8fb6cd20f..1de1a0476 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 df0a24f7b..4fae5e1a5 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 000000000..426d5ab10 --- /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 000000000..c81ade7f2 --- /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 000000000..0409d7629 --- /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 333a5ff98..3d0a248a2 100644 --- a/nano/lib/memory.hpp +++ b/nano/lib/memory.hpp @@ -48,6 +48,16 @@ private: 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 c9cca1030..84cb65f41 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 bf8137c65..ccf42ba35 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 000000000..d40de592a --- /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 8c5fdc2fe..9939ebf30 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 5e209f4d6..cf377cb68 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 @@ private: 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 7ee17cd1f..3097bc412 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 164064893..0336d10a0 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 @@ public: 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 000000000..fb24b82d3 --- /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 37c2786bf..5477769e7 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 6018a26e3..c4001a14a 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -43,8 +43,6 @@ add_library( bootstrap/peer_scoring.cpp cli.hpp cli.cpp - common.hpp - common.cpp confirming_set.hpp confirming_set.cpp confirmation_solicitor.hpp @@ -60,9 +58,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 @@ -151,6 +153,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 4d8c953f5..758752a08 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 1bd9e5833..7afafee75 100644 --- a/nano/node/bandwidth_limiter.hpp +++ b/nano/node/bandwidth_limiter.hpp @@ -50,4 +50,4 @@ private: 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 34d6956a8..7f47f79d0 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/account_sets.cpp b/nano/node/bootstrap/account_sets.cpp index 1754fab44..00b522a26 100644 --- a/nano/node/bootstrap/account_sets.cpp +++ b/nano/node/bootstrap/account_sets.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include #include @@ -354,4 +356,4 @@ nano::container_info nano::bootstrap::account_sets::container_info () const info.put ("blocking", blocking); info.put ("blocking_unknown", blocking_unknown); return info; -} \ No newline at end of file +} diff --git a/nano/node/bootstrap/account_sets.hpp b/nano/node/bootstrap/account_sets.hpp index c42853c41..5680600e4 100644 --- a/nano/node/bootstrap/account_sets.hpp +++ b/nano/node/bootstrap/account_sets.hpp @@ -19,8 +19,6 @@ namespace mi = boost::multi_index; namespace nano { -class stats; - namespace bootstrap { /** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */ @@ -162,4 +160,4 @@ namespace bootstrap info_t info () const; }; } -} \ No newline at end of file +} diff --git a/nano/node/bootstrap/bootstrap_service.cpp b/nano/node/bootstrap/bootstrap_service.cpp index 4b93c0d44..1f54cacb3 100644 --- a/nano/node/bootstrap/bootstrap_service.cpp +++ b/nano/node/bootstrap/bootstrap_service.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -1108,4 +1109,4 @@ nano::container_info nano::bootstrap_service::container_info () const nano::stat::detail nano::to_stat_detail (nano::bootstrap_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 c66d79d45..6128a1c3e 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 2921881b5..3de7e7dc8 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 644b241c9..50ca65655 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 81d771a5e..a7cb40598 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 17edecc60..4d83e0160 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 8024bb184..56daf3b85 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 06ea41350..7cd964aae 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 3ab73a765..718cbf680 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 5edab1f7f..891f88728 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 5dd98516d..c1ed629ef 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 000000000..22d17e963 --- /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 69d2a5065..1a44e9f24 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 d9bccad98..5cbb9b7b8 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 e934f6eb6..0e5c2f6cb 100644 --- a/nano/node/fwd.hpp +++ b/nano/node/fwd.hpp @@ -1,19 +1,13 @@ #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 bootstrap_config; @@ -21,7 +15,6 @@ class bootstrap_server; class bootstrap_service; class confirming_set; class election; -class ledger; class local_block_broadcaster; class local_vote_history; class logger; @@ -38,6 +31,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; @@ -56,4 +51,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 f8265733f..c4d3a0355 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 04d4901b3..323063976 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 4722177da..3cdb73bef 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 25d4df9e3..43dcf3f02 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -1,13 +1,16 @@ +#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 ad1a2201f..f136bd036 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 d2bed33ce..a88ed25f9 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 311867e21..9ee4e38c6 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 a5779d6a7..2b83df904 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 a2e819cc3..d665ee3f8 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 cba54744d..2a0e4d0a3 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 0ab498ed2..d1130271d 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 cafbcf964..af513eae4 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1,9 +1,11 @@ +#include #include #include #include #include #include #include +#include #include #include #include @@ -11,10 +13,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -38,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/online_reps.hpp b/nano/node/online_reps.hpp index 2838346f3..d8e60665d 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 3100bfe09..e209d5e63 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 15d13ffdd..6200446b5 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 @@ private: 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 cc542896a..437852e94 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 803039275..bdfc95611 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 6bc532787..a0eb4fe43 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 71c63ab0d..3c4b54ee1 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 @@ private: 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 b3dc58c40..b54eae4a5 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 c7892399e..cd9d68009 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 8465b7d2b..75faab069 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 668bbec6d..a95878dab 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 cb9c337a9..8e0fe8c31 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 6a4c6663e..8b7055c46 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 212dc1c37..8f860f58c 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 @@ private: 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 c62c47030..4be374eba 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 4c4d62c22..ca8d923f3 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 1b6f1e363..8e1aeeccc 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 @@ private: 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 55c63da64..66644665d 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 @@ private: 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 96085ae8b..c4971464d 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 4a90626f9..21f5fea04 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 3065bbd04..5703a8c73 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 36f9c4adf..4fedd3a04 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 c70bae9d3..b371941ac 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 e29c88cc9..faf3c273b 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 4d0c8ef54..283e78ac9 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 acf3d069c..0f80e4995 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 ed2d3d09c..37c6ef87c 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 f46cd6352..c5ee41827 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 18dd7df7a..ba65fe0dc 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 d2b8eab72..32a68d2bb 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 2a3895606..1a5eb0dbb 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 b3ce57fd8..1847ff850 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 bb55c37dc..dd97b9973 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 806f07645..e16a3f4e5 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 27cc4d150..cfc63f0b3 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 c495c1270..a0cbea2a4 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 1b18ca602..81bcec0c6 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 ee850d8d2..a40136f64 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 a68f70b35..af8d0a7a1 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 f5fd8e44f..92abdf01d 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 e1639bd26..b8f8ee110 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 1d57ae0cf..f6bb2076a 100644 --- a/nano/secure/fwd.hpp +++ b/nano/secure/fwd.hpp @@ -1,14 +1,17 @@ #pragma once -namespace nano::secure -{ -class transaction; -class write_transaction; -class read_transaction; -} - namespace nano { class account_info; +class ledger; +class ledger_cache; +class ledger_constants; +class network_params; class vote; -} \ No newline at end of file +} +namespace nano::secure +{ +class read_transaction; +class transaction; +class write_transaction; +} diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index d2857974d..4533eddcc 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 a9d52588a..85a32a8aa 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 c00e1cdb3..43273cab8 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 b2cbebef7..f2e1867df 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 9209bbf25..29a2c2804 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 296886634..b7b7e6c63 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 0737acf00..c4e24f149 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 096c7dc6a..83d12130d 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 708bec26e..f583c842f 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 938aa2566..b3fcffa9f 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 0fb509489..e3f4ef175 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 f36f837ef..13f00910f 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 7cc415a5f..12b81a143 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 9ecd1ff3a..febe31a89 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 transaction; -class write_transaction; +class confirmation_height; +class final_vote; +class online_weight; +class peer; +class pending; +class pruned; class read_transaction; -} \ No newline at end of file +class rep_weight; +class transaction; +class version; +class write_transaction; +} diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index fe6026fdf..75f3e5149 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 3bfcd22c3..d201fee17 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 758a5c72e..4071ea462 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 db2465e07..a2aa36a3c 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 f2c3c7712..8218fd22c 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 716be359c..017d61655 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