Merge branch 'develop' into remove-legacy-bootstrap-2

# Conflicts:
#	nano/node/bootstrap/account_sets.hpp
#	nano/node/bootstrap/bootstrap.cpp
#	nano/node/bootstrap/bootstrap.hpp
#	nano/node/bootstrap/bootstrap_attempt.hpp
#	nano/node/bootstrap/bootstrap_bulk_push.cpp
#	nano/node/bootstrap/bootstrap_bulk_push.hpp
#	nano/node/bootstrap/bootstrap_connections.cpp
#	nano/node/bootstrap/bootstrap_connections.hpp
#	nano/node/bootstrap/bootstrap_lazy.cpp
#	nano/node/json_handler.cpp
This commit is contained in:
Piotr Wójcik 2024-10-31 13:01:29 +01:00
commit 40d231061a
149 changed files with 934 additions and 702 deletions

View file

@ -35,6 +35,8 @@ endif()
if(MSVC) if(MSVC)
add_definitions(/MP) add_definitions(/MP)
add_definitions(
-D_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) # Suppress iterator warning
endif() endif()
set(CPACK_PACKAGE_VENDOR "Nano Currency") set(CPACK_PACKAGE_VENDOR "Nano Currency")

View file

@ -6,11 +6,13 @@
#include <nano/node/scheduler/component.hpp> #include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp> #include <nano/node/scheduler/manual.hpp>
#include <nano/node/scheduler/priority.hpp> #include <nano/node/scheduler/priority.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_router.hpp> #include <nano/node/vote_router.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp> #include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/chains.hpp> #include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

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

View file

@ -1,11 +1,12 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/lmdbconfig.hpp> #include <nano/lib/lmdbconfig.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/stats.hpp> #include <nano/lib/stats.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/lib/work.hpp> #include <nano/lib/work.hpp>
#include <nano/node/common.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/make_store.hpp> #include <nano/node/make_store.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/test_common/chains.hpp> #include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -4,6 +4,7 @@
#include <nano/node/scheduler/component.hpp> #include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp> #include <nano/node/scheduler/priority.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/chains.hpp> #include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,8 +1,10 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/epoch.hpp> #include <nano/lib/epoch.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/work.hpp> #include <nano/lib/work.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/core_test/fakes/work_peer.hpp> #include <nano/core_test/fakes/work_peer.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

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

View file

@ -1,4 +1,5 @@
#include <nano/node/fair_queue.hpp> #include <nano/node/fair_queue.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

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

View file

@ -12,6 +12,7 @@
#include <nano/node/vote_router.hpp> #include <nano/node/vote_router.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp> #include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/secure/vote.hpp>
#include <nano/store/rocksdb/rocksdb.hpp> #include <nano/store/rocksdb/rocksdb.hpp>
#include <nano/test_common/ledger_context.hpp> #include <nano/test_common/ledger_context.hpp>
#include <nano/test_common/make_store.hpp> #include <nano/test_common/make_store.hpp>

View file

@ -2,6 +2,7 @@
#include <nano/lib/memory.hpp> #include <nano/lib/memory.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/secure/vote.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>

View file

@ -1,8 +1,9 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/stream.hpp> #include <nano/lib/stream.hpp>
#include <nano/node/common.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/network.hpp> #include <nano/node/network.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/node/transport/message_deserializer.hpp> #include <nano/node/transport/message_deserializer.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -4,6 +4,7 @@
#include <nano/node/nodeconfig.hpp> #include <nano/node/nodeconfig.hpp>
#include <nano/node/scheduler/component.hpp> #include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp> #include <nano/node/scheduler/priority.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/node/transport/tcp_listener.hpp> #include <nano/node/transport/tcp_listener.hpp>
#include <nano/node/transport/tcp_socket.hpp> #include <nano/node/transport/tcp_socket.hpp>

View file

@ -1,7 +1,8 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/network_filter.hpp> #include <nano/lib/network_filter.hpp>
#include <nano/lib/stream.hpp> #include <nano/lib/stream.hpp>
#include <nano/node/common.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,6 +1,7 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/confirming_set.hpp> #include <nano/node/confirming_set.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
@ -19,6 +20,7 @@
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp> #include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/network.hpp> #include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>

View file

@ -6,6 +6,7 @@
#include <nano/node/transport/fake.hpp> #include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/chains.hpp> #include <nano/test_common/chains.hpp>
#include <nano/test_common/network.hpp> #include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>

View file

@ -5,6 +5,7 @@
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/node/local_vote_history.hpp> #include <nano/node/local_vote_history.hpp>
#include <nano/node/request_aggregator.hpp> #include <nano/node/request_aggregator.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_confirmed.hpp> #include <nano/secure/ledger_set_confirmed.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/thread_runner.hpp> #include <nano/lib/thread_runner.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/node/telemetry.hpp> #include <nano/node/telemetry.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/test_common/network.hpp> #include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/telemetry.hpp> #include <nano/test_common/telemetry.hpp>

View file

@ -2,10 +2,12 @@
#include <nano/lib/jsonconfig.hpp> #include <nano/lib/jsonconfig.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_processor.hpp> #include <nano/node/vote_processor.hpp>
#include <nano/node/vote_router.hpp> #include <nano/node/vote_router.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/chains.hpp> #include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,9 +1,10 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/node/common.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/local_vote_history.hpp> #include <nano/node/local_vote_history.hpp>
#include <nano/node/vote_generator.hpp> #include <nano/node/vote_generator.hpp>
#include <nano/node/vote_spacing.hpp> #include <nano/node/vote_spacing.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/system.hpp> #include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp> #include <nano/test_common/testutil.hpp>

View file

@ -1,6 +1,7 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/thread_runner.hpp> #include <nano/lib/thread_runner.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>

View file

@ -1,5 +1,7 @@
#include <nano/core_test/fakes/websocket_client.hpp> #include <nano/core_test/fakes/websocket_client.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/telemetry.hpp> #include <nano/node/telemetry.hpp>
#include <nano/node/transport/fake.hpp> #include <nano/node/transport/fake.hpp>

View file

@ -3,6 +3,7 @@
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/timer.hpp> #include <nano/lib/timer.hpp>
#include <nano/lib/work.hpp> #include <nano/lib/work.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/openclconfig.hpp> #include <nano/node/openclconfig.hpp>
#include <nano/node/openclwork.hpp> #include <nano/node/openclwork.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>

View file

@ -33,6 +33,7 @@ add_library(
char_traits.hpp char_traits.hpp
cli.hpp cli.hpp
cli.cpp cli.cpp
common.hpp
config.hpp config.hpp
config.cpp config.cpp
configbase.hpp configbase.hpp
@ -44,8 +45,11 @@ add_library(
env.cpp env.cpp
epoch.hpp epoch.hpp
epoch.cpp epoch.cpp
epochs.cpp
epochs.hpp
errors.hpp errors.hpp
errors.cpp errors.cpp
fwd.hpp
id_dispenser.hpp id_dispenser.hpp
interval.hpp interval.hpp
ipc.hpp ipc.hpp
@ -69,6 +73,7 @@ add_library(
network_filter.cpp network_filter.cpp
numbers.hpp numbers.hpp
numbers.cpp numbers.cpp
numbers_templ.hpp
object_stream.hpp object_stream.hpp
object_stream.cpp object_stream.cpp
object_stream_adapters.hpp object_stream_adapters.hpp
@ -110,7 +115,8 @@ add_library(
walletconfig.hpp walletconfig.hpp
walletconfig.cpp walletconfig.cpp
work.hpp work.hpp
work.cpp) work.cpp
work_version.hpp)
include_directories(${CMAKE_SOURCE_DIR}/submodules) include_directories(${CMAKE_SOURCE_DIR}/submodules)
include_directories( include_directories(

View file

@ -0,0 +1,216 @@
#include <nano/lib/block_sideband.hpp>
#include <nano/lib/block_type.hpp>
#include <nano/lib/object_stream.hpp>
#include <nano/lib/stream.hpp>
#include <bitset>
/*
* 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<uint8_t> (epoch));
result.set (7, is_send);
result.set (6, is_receive);
result.set (5, is_epoch);
return static_cast<uint8_t> (result.to_ulong ());
}
void nano::block_details::unpack (uint8_t details_a)
{
constexpr std::bitset<8> epoch_mask{ 0b00011111 };
auto as_bitset = static_cast<std::bitset<8>> (details_a);
is_send = as_bitset.test (7);
is_receive = as_bitset.test (6);
is_epoch = as_bitset.test (5);
epoch = static_cast<nano::epoch> ((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<uint8_t> (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<nano::epoch> (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);
}

View file

@ -1,19 +1,13 @@
#pragma once #pragma once
#include <nano/lib/block_type.hpp>
#include <nano/lib/epoch.hpp> #include <nano/lib/epoch.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/stream.hpp>
#include <nano/lib/timer.hpp> #include <nano/lib/timer.hpp>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
namespace nano
{
class object_stream;
}
namespace nano namespace nano
{ {
class block_details class block_details

View file

@ -5,8 +5,3 @@ std::string_view nano::to_string (nano::block_type type)
{ {
return nano::enum_util::name (type); return nano::enum_util::name (type);
} }
void nano::serialize_block_type (nano::stream & stream, const nano::block_type & type)
{
nano::write (stream, type);
}

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <nano/lib/stream.hpp>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
@ -19,8 +17,4 @@ enum class block_type : uint8_t
}; };
std::string_view to_string (block_type); 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 } // namespace nano

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/lib/uniquer.hpp> #include <nano/lib/uniquer.hpp>
namespace nano namespace nano

View file

@ -1,9 +1,13 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/block_type.hpp>
#include <nano/lib/block_uniquer.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/memory.hpp> #include <nano/lib/memory.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/stream.hpp>
#include <nano/lib/threading.hpp> #include <nano/lib/threading.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <boost/endian/conversion.hpp> #include <boost/endian/conversion.hpp>
@ -1582,7 +1586,7 @@ std::shared_ptr<nano::block> nano::deserialize_block_json (boost::property_tree:
void nano::serialize_block (nano::stream & stream_a, nano::block const & block_a) 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); 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 ("signature", signature);
obs.write ("work", work); 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<uint8_t> (epoch));
result.set (7, is_send);
result.set (6, is_receive);
result.set (5, is_epoch);
return static_cast<uint8_t> (result.to_ulong ());
}
void nano::block_details::unpack (uint8_t details_a)
{
constexpr std::bitset<8> epoch_mask{ 0b00011111 };
auto as_bitset = static_cast<std::bitset<8>> (details_a);
is_send = as_bitset.test (7);
is_receive = as_bitset.test (6);
is_epoch = as_bitset.test (5);
epoch = static_cast<nano::epoch> ((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<uint8_t> (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<nano::epoch> (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);
}

View file

@ -1,24 +1,25 @@
#pragma once #pragma once
#include <nano/lib/block_sideband.hpp> #include <nano/lib/block_sideband.hpp>
#include <nano/lib/block_uniquer.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/epoch.hpp> #include <nano/lib/epoch.hpp>
#include <nano/lib/errors.hpp> #include <nano/lib/errors.hpp>
#include <nano/lib/fwd.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/optional_ptr.hpp> #include <nano/lib/optional_ptr.hpp>
#include <nano/lib/stream.hpp>
#include <boost/property_tree/ptree_fwd.hpp> #include <boost/property_tree/ptree_fwd.hpp>
#include <optional>
typedef struct blake2b_state__ blake2b_state; typedef struct blake2b_state__ blake2b_state;
namespace nano namespace nano
{ {
class block_visitor; using block_uniquer = uniquer<nano::uint256_union, nano::block>;
class mutable_block_visitor; }
class object_stream;
namespace nano
{
class block class block
{ {
public: public:

View file

@ -1,9 +1,14 @@
#pragma once #pragma once
#include <nano/boost/asio/ip/tcp.hpp> namespace boost::asio::ip
{
class tcp;
template <typename InternetProtocol>
class basic_endpoint;
}
namespace nano namespace nano
{ {
using endpoint = boost::asio::ip::tcp::endpoint; using endpoint = boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>;
using tcp_endpoint = endpoint; using tcp_endpoint = endpoint;
} }

View file

@ -1,8 +1,10 @@
#include <nano/crypto/blake2/blake2.h> #include <nano/crypto/blake2/blake2.h>
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/env.hpp> #include <nano/lib/env.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/work_version.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>

View file

@ -105,15 +105,11 @@ enum class networks : uint16_t
std::string_view to_string (nano::networks); std::string_view to_string (nano::networks);
enum class work_version
{
unspecified,
work_1
};
enum class block_type : uint8_t; enum class block_type : uint8_t;
class root; class root;
class block; class block;
class block_details; class block_details;
enum class work_version;
class work_thresholds class work_thresholds
{ {

View file

@ -1,43 +1,6 @@
#include <nano/lib/epoch.hpp> #include <nano/lib/epoch.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <algorithm>
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<nano::epoch> (epoch_a);
bool is_valid_epoch (head_epoch >= std::underlying_type_t<nano::epoch> (nano::epoch::epoch_0));
return is_valid_epoch && (std::underlying_type_t<nano::epoch> (new_epoch_a) == (head_epoch + 1));
}
std::underlying_type_t<nano::epoch> nano::normalized_epoch (nano::epoch epoch_a) std::underlying_type_t<nano::epoch> nano::normalized_epoch (nano::epoch epoch_a)
{ {
// Currently assumes that the epoch versions in the enum are sequential. // Currently assumes that the epoch versions in the enum are sequential.

View file

@ -1,9 +1,8 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <cstdint>
#include <functional>
#include <type_traits> #include <type_traits>
#include <unordered_map>
namespace nano namespace nano
{ {
@ -31,42 +30,7 @@ struct hash<::nano::epoch>
{ {
std::size_t operator() (::nano::epoch const & epoch_a) const std::size_t operator() (::nano::epoch const & epoch_a) const
{ {
std::hash<std::underlying_type_t<::nano::epoch>> hash; return std::underlying_type_t<::nano::epoch> (epoch_a);
return hash (static_cast<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<nano::epoch, nano::epoch_info> epochs_m;
};
}

39
nano/lib/epochs.cpp Normal file
View file

@ -0,0 +1,39 @@
#include <nano/lib/epochs.hpp>
#include <nano/lib/utility.hpp>
#include <algorithm>
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<nano::epoch> (epoch_a);
bool is_valid_epoch (head_epoch >= std::underlying_type_t<nano::epoch> (nano::epoch::epoch_0));
return is_valid_epoch && (std::underlying_type_t<nano::epoch> (new_epoch_a) == (head_epoch + 1));
}

42
nano/lib/epochs.hpp Normal file
View file

@ -0,0 +1,42 @@
#pragma once
#include <nano/lib/epoch.hpp>
#include <nano/lib/numbers.hpp>
#include <cstdint>
#include <unordered_map>
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<nano::epoch, nano::epoch_info> epochs_m;
};
}

31
nano/lib/fwd.hpp Normal file
View file

@ -0,0 +1,31 @@
#pragma once
#include <cstdint>
#include <iosfwd>
struct uint8_char_traits;
namespace nano
{
class block;
enum class block_type : uint8_t;
class block_visitor;
class container_info;
enum class epoch : uint8_t;
class jsonconfig;
class mutable_block_visitor;
class network_constants;
class object_stream;
class thread_pool;
class tomlconfig;
template <typename Key, typename Value>
class uniquer;
enum class work_version;
using stream = std::basic_streambuf<uint8_t, uint8_char_traits>;
}
namespace nano::stat
{
enum class detail;
enum class dir;
}

View file

@ -48,6 +48,16 @@ private:
std::vector<std::function<void ()>> cleanup_funcs; std::vector<std::function<void ()>> 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 <typename T, typename... Args> template <typename T, typename... Args>
std::shared_ptr<T> make_shared (Args &&... args) std::shared_ptr<T> make_shared (Args &&... args)
{ {

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <cryptopp/seckey.h> #include <cryptopp/seckey.h>

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <boost/functional/hash.hpp> #include <boost/functional/hash_fwd.hpp>
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_int.hpp>
#include <array> #include <array>
@ -516,185 +516,53 @@ namespace difficulty
namespace std namespace std
{ {
template <> template <>
struct hash<::nano::uint128_union> struct hash<::nano::uint128_union>;
{
size_t operator() (::nano::uint128_union const & value) const noexcept
{
return value.qwords[0] + value.qwords[1];
}
};
template <> template <>
struct hash<::nano::uint256_union> 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 <> template <>
struct hash<::nano::public_key> struct hash<::nano::public_key>;
{
size_t operator() (::nano::public_key const & value) const noexcept
{
return hash<::nano::uint256_union>{}(value);
}
};
template <> template <>
struct hash<::nano::block_hash> struct hash<::nano::block_hash>;
{
size_t operator() (::nano::block_hash const & value) const noexcept
{
return hash<::nano::uint256_union>{}(value);
}
};
template <> template <>
struct hash<::nano::hash_or_account> 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 <> template <>
struct hash<::nano::root> struct hash<::nano::root>;
{
size_t operator() (::nano::root const & value) const noexcept
{
return hash<::nano::hash_or_account>{}(value);
}
};
template <> template <>
struct hash<::nano::link> struct hash<::nano::link>;
{
size_t operator() (::nano::link const & value) const noexcept
{
return hash<::nano::hash_or_account>{}(value);
}
};
template <> template <>
struct hash<::nano::raw_key> struct hash<::nano::raw_key>;
{
size_t operator() (::nano::raw_key const & value) const noexcept
{
return hash<::nano::uint256_union>{}(value);
}
};
template <> template <>
struct hash<::nano::wallet_id> struct hash<::nano::wallet_id>;
{
size_t operator() (::nano::wallet_id const & value) const noexcept
{
return hash<::nano::uint256_union>{}(value);
}
};
template <> template <>
struct hash<::nano::uint512_union> 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 <> template <>
struct hash<::nano::qualified_root> struct hash<::nano::qualified_root>;
{
size_t operator() (::nano::qualified_root const & value) const noexcept
{
return hash<::nano::uint512_union>{}(value);
}
};
} }
namespace boost namespace boost
{ {
template <> template <>
struct hash<::nano::uint128_union> struct hash<::nano::uint128_union>;
{
size_t operator() (::nano::uint128_union const & value) const noexcept
{
return std::hash<::nano::uint128_union> () (value);
}
};
template <> template <>
struct hash<::nano::uint256_union> struct hash<::nano::uint256_union>;
{
size_t operator() (::nano::uint256_union const & value) const noexcept
{
return std::hash<::nano::uint256_union> () (value);
}
};
template <> template <>
struct hash<::nano::public_key> struct hash<::nano::public_key>;
{
size_t operator() (::nano::public_key const & value) const noexcept
{
return std::hash<::nano::public_key> () (value);
}
};
template <> template <>
struct hash<::nano::block_hash> struct hash<::nano::block_hash>;
{
size_t operator() (::nano::block_hash const & value) const noexcept
{
return std::hash<::nano::block_hash> () (value);
}
};
template <> template <>
struct hash<::nano::hash_or_account> 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 <> template <>
struct hash<::nano::root> struct hash<::nano::root>;
{
size_t operator() (::nano::root const & value) const noexcept
{
return std::hash<::nano::root> () (value);
}
};
template <> template <>
struct hash<::nano::link> struct hash<::nano::link>;
{
size_t operator() (::nano::link const & value) const noexcept
{
return std::hash<::nano::link> () (value);
}
};
template <> template <>
struct hash<::nano::raw_key> struct hash<::nano::raw_key>;
{
size_t operator() (::nano::raw_key const & value) const noexcept
{
return std::hash<::nano::raw_key> () (value);
}
};
template <> template <>
struct hash<::nano::wallet_id> struct hash<::nano::wallet_id>;
{
size_t operator() (::nano::wallet_id const & value) const noexcept
{
return std::hash<::nano::wallet_id> () (value);
}
};
template <> template <>
struct hash<::nano::uint512_union> struct hash<::nano::uint512_union>;
{
size_t operator() (::nano::uint512_union const & value) const noexcept
{
return std::hash<::nano::uint512_union> () (value);
}
};
template <> template <>
struct hash<::nano::qualified_root> struct hash<::nano::qualified_root>;
{
size_t operator() (::nano::qualified_root const & value) const noexcept
{
return std::hash<::nano::qualified_root> () (value);
}
};
} }
/* /*

189
nano/lib/numbers_templ.hpp Normal file
View file

@ -0,0 +1,189 @@
#pragma once
#include <nano/lib/numbers.hpp>
#include <boost/functional/hash.hpp>
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);
}
};
}

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <nano/lib/utility.hpp>
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <nano/lib/locks.hpp>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <mutex> #include <mutex>

View file

@ -5,6 +5,7 @@
#include <nano/lib/thread_roles.hpp> #include <nano/lib/thread_roles.hpp>
#include <nano/lib/threading.hpp> #include <nano/lib/threading.hpp>
#include <nano/lib/work.hpp> #include <nano/lib/work.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/xorshift.hpp> #include <nano/node/xorshift.hpp>
#include <future> #include <future>
@ -41,7 +42,7 @@ nano::work_pool::work_pool (nano::network_constants & network_constants, unsigne
} }
for (auto i (0u); i < count; ++i) 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::thread_role::set (nano::thread_role::name::work);
nano::work_thread_reprioritize (); nano::work_thread_reprioritize ();
loop (i); loop (i);

View file

@ -8,10 +8,10 @@
#include <nano/node/openclwork.hpp> #include <nano/node/openclwork.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/thread/thread.hpp>
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <thread>
namespace nano namespace nano
{ {
@ -54,7 +54,7 @@ public:
nano::network_constants & network_constants; nano::network_constants & network_constants;
std::atomic<int> ticket; std::atomic<int> ticket;
bool done; bool done;
std::vector<boost::thread> threads; std::vector<std::thread> threads;
std::list<nano::work_item> pending; std::list<nano::work_item> pending;
mutable nano::mutex mutex{ mutex_identifier (mutexes::work_pool) }; mutable nano::mutex mutex{ mutex_identifier (mutexes::work_pool) };
nano::condition_variable producer_condition; nano::condition_variable producer_condition;

10
nano/lib/work_version.hpp Normal file
View file

@ -0,0 +1,10 @@
#pragma once
namespace nano
{
enum class work_version
{
unspecified,
work_1
};
}

View file

@ -1,8 +1,10 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/cli.hpp> #include <nano/lib/cli.hpp>
#include <nano/lib/thread_runner.hpp> #include <nano/lib/thread_runner.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/nano_node/daemon.hpp> #include <nano/nano_node/daemon.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/cli.hpp> #include <nano/node/cli.hpp>
@ -15,6 +17,7 @@
#include <nano/node/transport/inproc.hpp> #include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/vote.hpp>
#include <nano/store/pending.hpp> #include <nano/store/pending.hpp>
#include <boost/dll/runtime_symbol_info.hpp> #include <boost/dll/runtime_symbol_info.hpp>

View file

@ -43,8 +43,6 @@ add_library(
bootstrap/peer_scoring.cpp bootstrap/peer_scoring.cpp
cli.hpp cli.hpp
cli.cpp cli.cpp
common.hpp
common.cpp
confirming_set.hpp confirming_set.hpp
confirming_set.cpp confirming_set.cpp
confirmation_solicitor.hpp confirmation_solicitor.hpp
@ -60,9 +58,13 @@ add_library(
election_behavior.hpp election_behavior.hpp
election_insertion_result.hpp election_insertion_result.hpp
election_status.hpp election_status.hpp
endpoint.cpp
endpoint.hpp
endpoint_templ.hpp
epoch_upgrader.hpp epoch_upgrader.hpp
epoch_upgrader.cpp epoch_upgrader.cpp
fair_queue.hpp fair_queue.hpp
fwd.hpp
ipc/action_handler.hpp ipc/action_handler.hpp
ipc/action_handler.cpp ipc/action_handler.cpp
ipc/flatbuffers_handler.hpp ipc/flatbuffers_handler.hpp
@ -151,6 +153,7 @@ add_library(
transport/tcp_channel.cpp transport/tcp_channel.cpp
transport/fake.hpp transport/fake.hpp
transport/fake.cpp transport/fake.cpp
transport/fwd.hpp
transport/inproc.hpp transport/inproc.hpp
transport/inproc.cpp transport/inproc.cpp
transport/message_deserializer.hpp transport/message_deserializer.hpp

View file

@ -1,3 +1,4 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>

View file

@ -1,3 +1,4 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/threading.hpp> #include <nano/lib/threading.hpp>

View file

@ -3,6 +3,8 @@
#include <nano/node/bootstrap/account_sets.hpp> #include <nano/node/bootstrap/account_sets.hpp>
#include <nano/node/bootstrap/bootstrap_config.hpp> #include <nano/node/bootstrap/bootstrap_config.hpp>
#include <boost/range/iterator_range.hpp>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <vector> #include <vector>

View file

@ -19,8 +19,6 @@ namespace mi = boost::multi_index;
namespace nano namespace nano
{ {
class stats;
namespace bootstrap namespace bootstrap
{ {
/** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */ /** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */

View file

@ -1,3 +1,4 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/stats_enums.hpp> #include <nano/lib/stats_enums.hpp>

View file

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

View file

@ -1,4 +1,5 @@
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/stats.hpp>
#include <nano/lib/thread_roles.hpp> #include <nano/lib/thread_roles.hpp>
#include <nano/node/confirming_set.hpp> #include <nano/node/confirming_set.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>

View file

@ -1,10 +1,12 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/lib/observer_set.hpp> #include <nano/lib/observer_set.hpp>
#include <nano/lib/thread_pool.hpp> #include <nano/lib/thread_pool.hpp>
#include <nano/node/fwd.hpp> #include <nano/node/fwd.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/secure/fwd.hpp>
#include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp> #include <boost/multi_index/member.hpp>

View file

@ -5,6 +5,7 @@
#include <boost/algorithm/string/erase.hpp> #include <boost/algorithm/string/erase.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/range/iterator_range.hpp>
std::shared_ptr<request_type> nano::distributed_work::peer_request::get_prepared_json_request (std::string const & request_string_a) const std::shared_ptr<request_type> nano::distributed_work::peer_request::get_prepared_json_request (std::string const & request_string_a) const
{ {

View file

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

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <atomic> #include <atomic>
#include <functional> #include <functional>

View file

@ -9,6 +9,7 @@
#include <nano/node/vote_generator.hpp> #include <nano/node/vote_generator.hpp>
#include <nano/node/vote_router.hpp> #include <nano/node/vote_router.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
using namespace std::chrono; using namespace std::chrono;

View file

@ -2,6 +2,7 @@
#include <nano/lib/id_dispenser.hpp> #include <nano/lib/id_dispenser.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/lib/stats_enums.hpp> #include <nano/lib/stats_enums.hpp>
#include <nano/node/election_status.hpp> #include <nano/node/election_status.hpp>
#include <nano/node/vote_with_weight_info.hpp> #include <nano/node/vote_with_weight_info.hpp>

View file

@ -2,10 +2,11 @@
#include <nano/lib/memory.hpp> #include <nano/lib/memory.hpp>
#include <nano/lib/stream.hpp> #include <nano/lib/stream.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/network.hpp> #include <nano/node/network.hpp>
#include <nano/node/wallet.hpp> #include <nano/node/wallet.hpp>
#include <nano/secure/vote.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
@ -27,6 +28,12 @@ uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint1
return result; 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 nano::parse_port (std::string const & string_a, uint16_t & port_a)
{ {
bool result = false; bool result = false;

View file

@ -1,13 +1,15 @@
#pragma once #pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/memory.hpp>
#include <nano/lib/network_filter.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <bitset> #include <cstdint>
#include <optional> #include <optional>
#include <string>
namespace boost::asio::ip
{
class address;
}
namespace nano namespace nano
{ {
@ -18,16 +20,11 @@ bool parse_endpoint (std::string const &, nano::endpoint &);
std::optional<nano::endpoint> parse_endpoint (std::string const &); std::optional<nano::endpoint> parse_endpoint (std::string const &);
bool parse_tcp_endpoint (std::string const &, nano::tcp_endpoint &); 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 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 namespace
{ {
uint64_t endpoint_hash_raw (nano::endpoint const & endpoint_a)
{
uint64_t result (nano::ip_address_hash_raw (endpoint_a.address (), endpoint_a.port ()));
return result;
}
template <std::size_t size> template <std::size_t size>
struct endpoint_hash struct endpoint_hash
{ {
@ -38,7 +35,7 @@ struct endpoint_hash<8>
{ {
std::size_t operator() (nano::endpoint const & endpoint_a) const 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 std::size_t operator() (nano::endpoint const & endpoint_a) const
{ {
uint64_t big (endpoint_hash_raw (endpoint_a)); uint64_t big = nano::endpoint_hash_raw (endpoint_a);
uint32_t result (static_cast<uint32_t> (big) ^ static_cast<uint32_t> (big >> 32)); uint32_t result (static_cast<uint32_t> (big) ^ static_cast<uint32_t> (big >> 32));
return result; return result;
} }
@ -82,60 +79,19 @@ struct ip_address_hash<4>
namespace std namespace std
{ {
template <> template <>
struct hash<::nano::endpoint> struct hash<::nano::endpoint>;
{
std::size_t operator() (::nano::endpoint const & endpoint_a) const
{
endpoint_hash<sizeof (std::size_t)> ehash;
return ehash (endpoint_a);
}
};
#ifndef BOOST_ASIO_HAS_STD_HASH #ifndef BOOST_ASIO_HAS_STD_HASH
template <> template <>
struct hash<boost::asio::ip::address> struct hash<boost::asio::ip::address>;
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
ip_address_hash<sizeof (std::size_t)> ihash;
return ihash (ip_a);
}
};
#endif #endif
} }
namespace boost namespace boost
{ {
template <> template <>
struct hash<::nano::endpoint> struct hash<::nano::endpoint>;
{
std::size_t operator() (::nano::endpoint const & endpoint_a) const
{
std::hash<::nano::endpoint> hash;
return hash (endpoint_a);
}
};
template <> template <>
struct hash<boost::asio::ip::address> struct hash<boost::asio::ip::address>;
{
std::size_t operator() (boost::asio::ip::address const & ip_a) const
{
std::hash<boost::asio::ip::address> hash;
return hash (ip_a);
}
};
}
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;
};
} }

View file

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

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/threading.hpp> #include <nano/lib/threading.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/epoch_upgrader.hpp> #include <nano/node/epoch_upgrader.hpp>
#include <nano/node/node.hpp> #include <nano/node/node.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>

View file

@ -1,22 +1,18 @@
#pragma once #pragma once
#include <nano/lib/epoch.hpp> #include <nano/lib/fwd.hpp>
#include <nano/lib/locks.hpp> #include <nano/lib/locks.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/node/fwd.hpp>
#include <nano/secure/fwd.hpp>
#include <nano/store/fwd.hpp>
#include <cstdint>
#include <future> #include <future>
namespace nano namespace nano
{ {
class node;
class ledger;
namespace store
{
class component;
}
class network_params;
class epoch_upgrader final class epoch_upgrader final
{ {
public: public:

View file

@ -1,19 +1,13 @@
#pragma once #pragma once
#include <nano/lib/fwd.hpp>
#include <nano/node/transport/fwd.hpp> #include <nano/node/transport/fwd.hpp>
#include <nano/secure/fwd.hpp> #include <nano/secure/fwd.hpp>
#include <nano/store/fwd.hpp> #include <nano/store/fwd.hpp>
// TODO: Move to lib/fwd.hpp
namespace nano
{
class block;
class container_info;
class thread_pool;
}
namespace nano namespace nano
{ {
class account_sets_config;
class active_elections; class active_elections;
class block_processor; class block_processor;
class bootstrap_config; class bootstrap_config;
@ -21,7 +15,6 @@ class bootstrap_server;
class bootstrap_service; class bootstrap_service;
class confirming_set; class confirming_set;
class election; class election;
class ledger;
class local_block_broadcaster; class local_block_broadcaster;
class local_vote_history; class local_vote_history;
class logger; class logger;
@ -38,6 +31,8 @@ class rep_crawler;
class rep_tiers; class rep_tiers;
class stats; class stats;
class vote_cache; class vote_cache;
enum class vote_code;
enum class vote_source;
class vote_generator; class vote_generator;
class vote_processor; class vote_processor;
class vote_router; class vote_router;

View file

@ -1,3 +1,4 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/node/ipc/flatbuffers_util.hpp> #include <nano/node/ipc/flatbuffers_util.hpp>

View file

@ -2,6 +2,12 @@
#include <nano/lib/tomlconfig.hpp> #include <nano/lib/tomlconfig.hpp>
#include <nano/node/ipc/ipc_config.hpp> #include <nano/node/ipc/ipc_config.hpp>
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::error nano::ipc::ipc_config::serialize_toml (nano::tomlconfig & toml) const
{ {
nano::tomlconfig tcp_l; nano::tomlconfig tcp_l;

View file

@ -2,12 +2,12 @@
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/errors.hpp> #include <nano/lib/errors.hpp>
#include <nano/lib/fwd.hpp>
#include <string> #include <string>
namespace nano namespace nano
{ {
class tomlconfig;
namespace ipc namespace ipc
{ {
/** Base class for transport configurations */ /** Base class for transport configurations */
@ -46,11 +46,7 @@ namespace ipc
class ipc_config_tcp_socket : public ipc_config_transport class ipc_config_tcp_socket : public ipc_config_transport
{ {
public: public:
ipc_config_tcp_socket (nano::network_constants & network_constants) : ipc_config_tcp_socket (nano::network_constants & network_constants);
network_constants{ network_constants },
port{ network_constants.default_ipc_port }
{
}
nano::network_constants & network_constants; nano::network_constants & network_constants;
/** Listening port */ /** Listening port */
uint16_t port; uint16_t port;

View file

@ -1,13 +1,16 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/json_error_response.hpp> #include <nano/lib/json_error_response.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/stats_sinks.hpp> #include <nano/lib/stats_sinks.hpp>
#include <nano/lib/timer.hpp> #include <nano/lib/timer.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/bootstrap/bootstrap_service.hpp> #include <nano/node/bootstrap/bootstrap_service.hpp>
#include <nano/node/common.hpp>
#include <nano/node/confirming_set.hpp> #include <nano/node/confirming_set.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/json_handler.hpp> #include <nano/node/json_handler.hpp>
#include <nano/node/node.hpp> #include <nano/node/node.hpp>
#include <nano/node/node_rpc_config.hpp> #include <nano/node/node_rpc_config.hpp>

View file

@ -8,6 +8,8 @@
#include <nano/node/node.hpp> #include <nano/node/node.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <boost/range/iterator_range.hpp>
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) : 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 }, config{ config_a },
node{ node_a }, node{ node_a },

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/interval.hpp>
#include <nano/lib/locks.hpp> #include <nano/lib/locks.hpp>
#include <nano/lib/processing_queue.hpp> #include <nano/lib/processing_queue.hpp>
#include <nano/lib/rate_limiting.hpp> #include <nano/lib/rate_limiting.hpp>

View file

@ -2,6 +2,7 @@
#include <nano/lib/locks.hpp> #include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/node/fwd.hpp> #include <nano/node/fwd.hpp>
#include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/hashed_index.hpp>

View file

@ -3,6 +3,7 @@
#include <nano/node/message_processor.hpp> #include <nano/node/message_processor.hpp>
#include <nano/node/node.hpp> #include <nano/node/node.hpp>
#include <nano/node/telemetry.hpp> #include <nano/node/telemetry.hpp>
#include <nano/secure/vote.hpp>
nano::message_processor::message_processor (message_processor_config const & config_a, nano::node & node_a) : nano::message_processor::message_processor (message_processor_config const & config_a, nano::node & node_a) :
config{ config_a }, config{ config_a },

View file

@ -1,15 +1,18 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/lib/memory.hpp> #include <nano/lib/memory.hpp>
#include <nano/lib/stats_enums.hpp> #include <nano/lib/stats_enums.hpp>
#include <nano/lib/stream.hpp> #include <nano/lib/stream.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/lib/work.hpp> #include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp> #include <nano/node/election.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp> #include <nano/node/messages.hpp>
#include <nano/node/network.hpp> #include <nano/node/network.hpp>
#include <nano/secure/vote.hpp>
#include <boost/asio/ip/address_v6.hpp> #include <boost/asio/ip/address_v6.hpp>
#include <boost/endian/conversion.hpp> #include <boost/endian/conversion.hpp>
@ -1873,7 +1876,7 @@ void nano::asc_pull_ack::blocks_payload::serialize (nano::stream & stream) const
nano::serialize_block (stream, *block); nano::serialize_block (stream, *block);
} }
// For convenience, end with null block terminator // 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) void nano::asc_pull_ack::blocks_payload::deserialize (nano::stream & stream)

View file

@ -1,19 +1,19 @@
#pragma once #pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/lib/asio.hpp> #include <nano/lib/asio.hpp>
#include <nano/lib/block_uniquer.hpp>
#include <nano/lib/config.hpp> #include <nano/lib/config.hpp>
#include <nano/lib/errors.hpp> #include <nano/lib/errors.hpp>
#include <nano/lib/jsonconfig.hpp> #include <nano/lib/fwd.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/memory.hpp> #include <nano/lib/memory.hpp>
#include <nano/lib/network_filter.hpp> #include <nano/lib/network_filter.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/object_stream.hpp> #include <nano/lib/object_stream.hpp>
#include <nano/lib/stats_enums.hpp> #include <nano/lib/stats_enums.hpp>
#include <nano/lib/stream.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/common.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <nano/secure/fwd.hpp>
#include <bitset> #include <bitset>
#include <cstdint> #include <cstdint>
@ -22,6 +22,12 @@
#include <variant> #include <variant>
#include <vector> #include <vector>
namespace nano
{
using block_uniquer = uniquer<nano::uint256_union, nano::block>;
using vote_uniquer = uniquer<nano::block_hash, nano::vote>;
}
namespace nano namespace nano
{ {
/** /**

View file

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

View file

@ -1,9 +1,11 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/stream.hpp> #include <nano/lib/stream.hpp>
#include <nano/lib/thread_pool.hpp> #include <nano/lib/thread_pool.hpp>
#include <nano/lib/thread_runner.hpp> #include <nano/lib/thread_runner.hpp>
#include <nano/lib/tomlconfig.hpp> #include <nano/lib/tomlconfig.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp> #include <nano/node/active_elections.hpp>
#include <nano/node/backlog_population.hpp> #include <nano/node/backlog_population.hpp>
#include <nano/node/bandwidth_limiter.hpp> #include <nano/node/bandwidth_limiter.hpp>
@ -11,10 +13,10 @@
#include <nano/node/bootstrap/bootstrap_service.hpp> #include <nano/node/bootstrap/bootstrap_service.hpp>
#include <nano/node/bootstrap_weights_beta.hpp> #include <nano/node/bootstrap_weights_beta.hpp>
#include <nano/node/bootstrap_weights_live.hpp> #include <nano/node/bootstrap_weights_live.hpp>
#include <nano/node/common.hpp>
#include <nano/node/confirming_set.hpp> #include <nano/node/confirming_set.hpp>
#include <nano/node/daemonconfig.hpp> #include <nano/node/daemonconfig.hpp>
#include <nano/node/election_status.hpp> #include <nano/node/election_status.hpp>
#include <nano/node/endpoint.hpp>
#include <nano/node/local_block_broadcaster.hpp> #include <nano/node/local_block_broadcaster.hpp>
#include <nano/node/local_vote_history.hpp> #include <nano/node/local_vote_history.hpp>
#include <nano/node/make_store.hpp> #include <nano/node/make_store.hpp>
@ -38,6 +40,7 @@
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp> #include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp> #include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/secure/vote.hpp>
#include <nano/store/component.hpp> #include <nano/store/component.hpp>
#include <nano/store/rocksdb/rocksdb.hpp> #include <nano/store/rocksdb/rocksdb.hpp>

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>

View file

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

View file

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

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <nano/boost/asio/ip/tcp.hpp>
#include <nano/lib/locks.hpp> #include <nano/lib/locks.hpp>
#include <miniupnp/miniupnpc/include/miniupnpc.h> #include <miniupnp/miniupnpc/include/miniupnpc.h>

View file

@ -2,6 +2,7 @@
#include <nano/lib/locks.hpp> #include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>
#include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/hashed_index.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/lib/enum_util.hpp> #include <nano/lib/enum_util.hpp>
#include <nano/lib/logging.hpp> #include <nano/lib/logging.hpp>
#include <nano/lib/stats.hpp>
#include <nano/lib/thread_roles.hpp> #include <nano/lib/thread_roles.hpp>
#include <nano/node/online_reps.hpp> #include <nano/node/online_reps.hpp>
#include <nano/node/rep_tiers.hpp> #include <nano/node/rep_tiers.hpp>

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>

View file

@ -2,6 +2,7 @@
#include <nano/node/node.hpp> #include <nano/node/node.hpp>
#include <nano/node/repcrawler.hpp> #include <nano/node/repcrawler.hpp>
#include <nano/secure/ledger.hpp> #include <nano/secure/ledger.hpp>
#include <nano/secure/vote.hpp>
#include <ranges> #include <ranges>

View file

@ -10,6 +10,7 @@
#include <boost/multi_index/member.hpp> #include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp> #include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index_container.hpp> #include <boost/multi_index_container.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>

View file

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

View file

@ -1,5 +1,8 @@
#pragma once #pragma once
#include <nano/lib/errors.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/numbers_templ.hpp>
#include <nano/node/fwd.hpp> #include <nano/node/fwd.hpp>
#include <nano/secure/common.hpp> #include <nano/secure/common.hpp>

View file

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

View file

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

View file

@ -4,7 +4,7 @@
#include <nano/lib/object_stream.hpp> #include <nano/lib/object_stream.hpp>
#include <nano/lib/stats.hpp> #include <nano/lib/stats.hpp>
#include <nano/node/bandwidth_limiter.hpp> #include <nano/node/bandwidth_limiter.hpp>
#include <nano/node/common.hpp> #include <nano/node/endpoint.hpp>
#include <nano/node/messages.hpp> #include <nano/node/messages.hpp>
#include <nano/node/transport/tcp_socket.hpp> #include <nano/node/transport/tcp_socket.hpp>

Some files were not shown because too many files have changed in this diff Show more