diff --git a/CMakeLists.txt b/CMakeLists.txt index 73269ba..ea8f4b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,12 @@ endif() message(STATUS "Knuth: Cryptocurrency: ${CURRENCY}") +# -------------------------------------------------------------------------------- +string(TIMESTAMP KTK_NODE_BUILD_TIMESTAMP "%s" UTC) +message(STATUS "KTK_NODE_BUILD_TIMESTAMP: ${KTK_NODE_BUILD_TIMESTAMP}") +add_definitions(-DKTK_NODE_BUILD_TIMESTAMP=${KTK_NODE_BUILD_TIMESTAMP}) +# -------------------------------------------------------------------------------- + if (NOT GLOBAL_BUILD) @@ -141,6 +147,7 @@ endif() set(kth_sources_just_legacy src/configuration.cpp + src/executor/executor_info.cpp src/parser.cpp src/settings.cpp src/version.cpp @@ -194,6 +201,7 @@ set(kth_headers include/kth/node/configuration.hpp include/kth/node/user_agent.hpp include/kth/node/executor/executor.hpp + include/kth/node/executor/executor_info.hpp include/kth/node/define.hpp include/kth/node/utility/reservation.hpp diff --git a/include/kth/node/executor/executor.hpp b/include/kth/node/executor/executor.hpp index 064979b..9d54f63 100644 --- a/include/kth/node/executor/executor.hpp +++ b/include/kth/node/executor/executor.hpp @@ -13,15 +13,10 @@ #include #include +#include namespace kth::node { -std::string_view microarchitecture(); -std::string_view march_names(); -std::string_view currency_symbol(); -std::string_view currency(); -std::string_view db_type(kth::database::db_mode_type db_mode); - class executor { public: executor(kth::node::configuration const& config, bool stdout_enabled = true); @@ -128,10 +123,6 @@ class executor { #define KTH_BLOCKCHAIN_CORES_INIT "Blockchain configured to use {} threads." #define KTH_NETWORK_CORES_INIT "Networking configured to use {} threads." -#define KTH_DB_TYPE_FULL "full-indexed" -#define KTH_DB_TYPE_BLOCKS "blocks-indexed" -#define KTH_DB_TYPE_PRUNED "pruned" - } // namespace kth::node #endif /*KTH_NODE_EXE_EXECUTOR_HPP_*/ diff --git a/include/kth/node/executor/executor_info.hpp b/include/kth/node/executor/executor_info.hpp new file mode 100644 index 0000000..a617bf9 --- /dev/null +++ b/include/kth/node/executor/executor_info.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2016-2024 Knuth Project developers. +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef KTH_NODE_EXE_EXECUTOR_INFO_HPP_ +#define KTH_NODE_EXE_EXECUTOR_INFO_HPP_ + +#include + +#include + +namespace kth::node { + +std::string_view microarchitecture(); +std::string_view march_names(); +std::string_view currency_symbol(); +std::string_view currency(); +std::string_view db_type(kth::database::db_mode_type db_mode); +uint32_t build_timestamp(); + +} // namespace kth::node + +#define KTH_DB_TYPE_FULL "full-indexed" +#define KTH_DB_TYPE_BLOCKS "blocks-indexed" +#define KTH_DB_TYPE_PRUNED "pruned" + + +#endif // KTH_NODE_EXE_EXECUTOR_INFO_HPP_ diff --git a/src/executor/executor.cpp b/src/executor/executor.cpp index 83efa6f..11e61c2 100644 --- a/src/executor/executor.cpp +++ b/src/executor/executor.cpp @@ -52,38 +52,6 @@ static constexpr int directory_exists = 0; static constexpr int directory_not_found = 2; static auto const mode = std::ofstream::out | std::ofstream::app; -std::string_view microarchitecture() { - return KTH_MICROARCHITECTURE_STR; -} - -std::string_view march_names() { -#if defined(KTH_MARCH_NAMES_FULL_STR) - return KTH_MARCH_NAMES_FULL_STR; -#else - return "unknown"; -#endif -} - -std::string_view currency_symbol() { - return KTH_CURRENCY_SYMBOL_STR; -} - -std::string_view currency() { - return KTH_CURRENCY_STR; -} - -std::string_view db_type(kth::database::db_mode_type db_mode) { - std::string_view db_type_str; - if (db_mode == db_mode_type::full) { - return KTH_DB_TYPE_FULL; - } - if (db_mode == db_mode_type::blocks) { - return KTH_DB_TYPE_BLOCKS; - } - // db_mode == db_mode_type::pruned - return KTH_DB_TYPE_PRUNED; -} - std::promise executor::stopping_; //NOLINT executor::executor(kth::node::configuration const& config, bool stdout_enabled /*= true*/) @@ -429,7 +397,7 @@ void executor::initialize_output(std::string_view extra, db_mode_type db_mode) { LOG_INFO(LOG_NODE, KTH_DEBUG_BUILD_INIT); #endif - LOG_INFO(LOG_NODE, fmt::format(KTH_NETWORK_INIT, name(kth::get_network(config_.network.identifier, config_.network.inbound_port == 488333)), config_.network.identifier)); + LOG_INFO(LOG_NODE, fmt::format(KTH_NETWORK_INIT, name(kth::get_network(config_.network.identifier, config_.network.inbound_port == 48333)), config_.network.identifier)); LOG_INFO(LOG_NODE, fmt::format(KTH_BLOCKCHAIN_CORES_INIT, kth::thread_ceiling(config_.chain.cores))); LOG_INFO(LOG_NODE, fmt::format(KTH_NETWORK_CORES_INIT, kth::thread_ceiling(config_.network.threads))); } diff --git a/src/executor/executor_info.cpp b/src/executor/executor_info.cpp new file mode 100644 index 0000000..fd6d185 --- /dev/null +++ b/src/executor/executor_info.cpp @@ -0,0 +1,51 @@ +// Copyright (c) 2016-2024 Knuth Project developers. +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +namespace kth::node { + +using namespace kth::database; + +std::string_view microarchitecture() { + return KTH_MICROARCHITECTURE_STR; +} + +std::string_view march_names() { +#if defined(KTH_MARCH_NAMES_FULL_STR) + return KTH_MARCH_NAMES_FULL_STR; +#else + return "unknown"; +#endif +} + +std::string_view currency_symbol() { + return KTH_CURRENCY_SYMBOL_STR; +} + +std::string_view currency() { + return KTH_CURRENCY_STR; +} + +std::string_view db_type(kth::database::db_mode_type db_mode) { + std::string_view db_type_str; + if (db_mode == db_mode_type::full) { + return KTH_DB_TYPE_FULL; + } + if (db_mode == db_mode_type::blocks) { + return KTH_DB_TYPE_BLOCKS; + } + // db_mode == db_mode_type::pruned + return KTH_DB_TYPE_PRUNED; +} + +uint32_t build_timestamp() { +#ifdef KTK_NODE_BUILD_TIMESTAMP + return KTK_NODE_BUILD_TIMESTAMP; +#else + return 0; +#endif +} + +} // namespace kth::node