Skip to content

Commit

Permalink
Merge pull request #4287 from clemahieu/nano_store_cleanup
Browse files Browse the repository at this point in the history
This is a sequence of cleanup commits preparing for the extraction of the nano::store library.
  • Loading branch information
clemahieu authored Sep 20, 2023
2 parents fa2151f + 90ced1a commit 3e0ff04
Show file tree
Hide file tree
Showing 67 changed files with 446 additions and 478 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4)
cmake_minimum_required(VERSION 3.14)

if(CMAKE_VERSION VERSION_GREATER 3.12 OR CMAKE_VERSION VERSION_EQUAL 3.12)
# find_package uses <PACKAGENAME>_ROOT variables
Expand Down Expand Up @@ -547,7 +547,8 @@ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-DCRYPTOPP_DISABLE_MIXED_ASM -DCRYPTOPP_DISABLE_ASM)
message(
"CryptoPP with disabled ASM for ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}"
STATUS
"CryptoPP with disabled ASM for ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}"
)
endif()
add_definitions(-DCRYPTOPP_DISABLE_SHANI)
Expand Down Expand Up @@ -774,7 +775,7 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
nano_wallet ${PLATFORM_GUI_TARGET_PROPERTIES} ${PLATFORM_WALLET_SOURCE}
nano/nano_wallet/entry.cpp nano/nano_wallet/icon.hpp ${RES})

target_link_libraries(nano_wallet rpc node qt)
target_link_libraries(nano_wallet Boost::process rpc node qt)

if(WIN32)
target_link_libraries(nano_wallet Qt5::WinExtras)
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/lmdb/lmdb.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/rocksdb/rocksdb.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/utility.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/bootstrap_ascending.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/stats.hpp>
#include <nano/node/bootstrap_ascending/service.hpp>
#include <nano/node/make_store.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down
1 change: 1 addition & 0 deletions nano/core_test/confirmation_height.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down
1 change: 1 addition & 0 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <nano/lib/stats.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/rocksdb/rocksdb.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <gtest/gtest.h>

#include <boost/filesystem.hpp>

#include <chrono>
#include <regex>
#include <thread>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/config.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp>
#include <nano/node/scheduler/priority.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/processor_service.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/stats.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/make_store.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/store.hpp>
#include <nano/secure/utility.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/socket.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/boost/asio/ip/address_v6.hpp>
#include <nano/boost/asio/ip/network_v6.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/transport/socket.hpp>
#include <nano/test_common/system.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/system.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <nano/lib/thread_runner.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <gtest/gtest.h>

#include <boost/filesystem.hpp>

#include <numeric>
#include <sstream>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/utility.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/lib/optional_ptr.hpp>
#include <nano/lib/rate_limiting.hpp>
#include <nano/lib/threading.hpp>
#include <nano/lib/thread_pool.hpp>
#include <nano/lib/timer.hpp>
#include <nano/lib/utility.hpp>
#include <nano/secure/utility.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/lmdb/wallet_value.hpp>
#include <nano/test_common/system.hpp>
Expand Down
3 changes: 2 additions & 1 deletion nano/ipc_flatbuffers_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ file(GLOB files
foreach(file ${files})
get_filename_component(flatbuffers_filename ${file} NAME_WE)
message(
"Generating flatbuffers code for: ${flatbuffers_filename} into ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers"
STATUS
"Generating flatbuffers code for: ${flatbuffers_filename} into ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers"
)

configure_file(
Expand Down
4 changes: 4 additions & 0 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ add_library(
stats_enums.hpp
stats_enums.cpp
stream.hpp
thread_pool.hpp
thread_pool.cpp
thread_roles.hpp
thread_roles.cpp
thread_runner.hpp
thread_runner.cpp
threading.hpp
threading.cpp
timer.hpp
Expand Down
74 changes: 0 additions & 74 deletions nano/lib/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,48 +282,11 @@ std::string nano::error_config_messages::message (int ev) const
return "Invalid error code";
}

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
char const * nano::error_conversion::detail::generic_category::name () const noexcept
{
return boost::system::generic_category ().name ();
}

std::string nano::error_conversion::detail::generic_category::message (int value) const
{
return boost::system::generic_category ().message (value);
}

std::error_category const & nano::error_conversion::generic_category ()
{
static detail::generic_category instance;
return instance;
}

std::error_code nano::error_conversion::convert (boost::system::error_code const & error)
{
if (error.category () == boost::system::generic_category ())
{
return std::error_code (error.value (),
nano::error_conversion::generic_category ());
}

debug_assert (false);
return nano::error_common::invalid_type_conversion;
}
#endif

nano::error::error (std::error_code code_a)
{
code = code_a;
}

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
nano::error::error (boost::system::error_code const & code_a)
{
code = std::make_error_code (static_cast<std::errc> (code_a.value ()));
}
#endif

nano::error::error (std::string message_a)
{
code = nano::error_common::generic;
Expand Down Expand Up @@ -358,24 +321,6 @@ nano::error & nano::error::operator= (std::error_code const code_a)
return *this;
}

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
/** Assign boost error code (as converted to std::error_code) */
nano::error & nano::error::operator= (boost::system::error_code const & code_a)
{
code = nano::error_conversion::convert (code_a);
message.clear ();
return *this;
}

/** Assign boost error code (as converted to std::error_code) */
nano::error & nano::error::operator= (boost::system::errc::errc_t const & code_a)
{
code = nano::error_conversion::convert (boost::system::errc::make_error_code (code_a));
message.clear ();
return *this;
}
#endif

/** Set the error to nano::error_common::generic and the error message to \p message_a */
nano::error & nano::error::operator= (std::string message_a)
{
Expand All @@ -398,14 +343,6 @@ bool nano::error::operator== (std::error_code const code_a) const
return code == code_a;
}

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
/** Return true if this#error_code equals the parameter */
bool nano::error::operator== (boost::system::error_code const code_a) const
{
return code.value () == code_a.value ();
}
#endif

/** Call the function iff the current error is zero */
nano::error & nano::error::then (std::function<nano::error &()> next)
{
Expand Down Expand Up @@ -495,14 +432,3 @@ nano::error & nano::error::clear ()
message.clear ();
return *this;
}

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
// TODO: theoretically, nothing besides template (partial) specializations should ever be added inside std...
namespace std
{
std::error_code make_error_code (boost::system::errc::errc_t const & e)
{
return std::error_code (static_cast<int> (e), ::nano::error_conversion::generic_category ());
}
}
#endif
58 changes: 0 additions & 58 deletions nano/lib/errors.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once

#include <boost/filesystem/operations.hpp>
#include <boost/system/error_code.hpp>

#include <algorithm>
#include <functional>
#include <memory>
Expand Down Expand Up @@ -197,51 +194,6 @@ REGISTER_ERROR_CODES (nano, error_rpc);
REGISTER_ERROR_CODES (nano, error_process);
REGISTER_ERROR_CODES (nano, error_config);

#if BOOST_VERSION >= 107800
/* no need for error_code bridge */
#else
#define NANO_USE_BOOST_TO_STD_ERROR_BRIDGE
#endif

#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
/* boost->std error_code bridge */
namespace nano
{
namespace error_conversion
{
std::error_category const & generic_category ();
}
}

namespace std
{
template <>
struct is_error_code_enum<boost::system::errc::errc_t>
: public std::true_type
{
};

std::error_code make_error_code (boost::system::errc::errc_t const & e);
}
namespace nano
{
namespace error_conversion
{
namespace detail
{
class generic_category : public std::error_category
{
public:
char const * name () const noexcept override;
std::string message (int value) const override;
};
}
std::error_category const & generic_category ();
std::error_code convert (boost::system::error_code const & error);
}
}
#endif

namespace nano
{
/** Adapter for std/boost::error_code, std::exception and bool flags to facilitate unified error handling */
Expand All @@ -253,24 +205,14 @@ class error
error (nano::error && error_a) = default;

error (std::error_code code_a);
#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
error (boost::system::error_code const & code_a);
#endif
error (std::string message_a);
error (std::exception const & exception_a);
error & operator= (nano::error const & err_a);
error & operator= (nano::error && err_a);
error & operator= (std::error_code code_a);
#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
error & operator= (boost::system::error_code const & code_a);
error & operator= (boost::system::errc::errc_t const & code_a);
#endif
error & operator= (std::string message_a);
error & operator= (std::exception const & exception_a);
bool operator== (std::error_code code_a) const;
#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE)
bool operator== (boost::system::error_code code_a) const;
#endif
error & then (std::function<nano::error &()> next);
template <typename... ErrorCode>
error & accept (ErrorCode... err)
Expand Down
2 changes: 1 addition & 1 deletion nano/lib/plat/darwin/thread_role.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <nano/lib/threading.hpp>
#include <nano/lib/thread_roles.hpp>

#include <pthread.h>

Expand Down
2 changes: 1 addition & 1 deletion nano/lib/plat/linux/thread_role.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <nano/lib/threading.hpp>
#include <nano/lib/thread_roles.hpp>

#include <pthread.h>

Expand Down
2 changes: 1 addition & 1 deletion nano/lib/plat/windows/thread_role.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <nano/lib/threading.hpp>
#include <nano/lib/thread_roles.hpp>

#include <processthreadsapi.h>

Expand Down
3 changes: 2 additions & 1 deletion nano/lib/processing_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/stats.hpp>
#include <nano/lib/thread_roles.hpp>
#include <nano/lib/threading.hpp>
#include <nano/lib/utility.hpp>

Expand Down Expand Up @@ -189,4 +190,4 @@ class processing_queue final
nano::condition_variable condition;
std::vector<std::thread> threads;
};
}
}
Loading

0 comments on commit 3e0ff04

Please sign in to comment.