Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions include/kth/node/executor/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@

#include <kth/infrastructure/handlers.hpp>
#include <kth/node.hpp>
#include <kth/node/executor/executor_info.hpp>

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);
Expand Down Expand Up @@ -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_*/
28 changes: 28 additions & 0 deletions include/kth/node/executor/executor_info.hpp
Original file line number Diff line number Diff line change
@@ -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 <string_view>

#include <kth/database/databases/property_code.hpp>

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_
34 changes: 1 addition & 33 deletions src/executor/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<kth::code> executor::stopping_; //NOLINT

executor::executor(kth::node::configuration const& config, bool stdout_enabled /*= true*/)
Expand Down Expand Up @@ -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)));
}
Expand Down
51 changes: 51 additions & 0 deletions src/executor/executor_info.cpp
Original file line number Diff line number Diff line change
@@ -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 <kth/node/executor/executor_info.hpp>

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