From 09ce03d612e54231694eee2fb9e5c807b2bfc341 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 25 Nov 2017 22:25:05 +0000 Subject: [PATCH] move includes around to lessen overall load --- contrib/epee/include/console_handler.h | 3 ++ contrib/epee/include/file_io_utils.h | 5 ++- contrib/epee/include/math_helper.h | 1 + contrib/epee/include/misc_log_ex.h | 19 --------- contrib/epee/include/misc_os_dependent.h | 3 ++ contrib/epee/include/net/http_client.h | 1 + contrib/epee/include/net/http_client_base.h | 6 +-- .../net/levin_protocol_handler_async.h | 2 + contrib/epee/include/net/net_helper.h | 7 ---- contrib/epee/include/net/net_utils_base.h | 37 +++--------------- contrib/epee/include/profile_tools.h | 2 + contrib/epee/include/readline_buffer.h | 2 - contrib/epee/include/reg_exp_definer.h | 2 +- .../keyvalue_serialization_overloads.h | 7 ++++ .../storages/portable_storage_from_json.h | 2 + .../storages/portable_storage_to_bin.h | 1 + .../portable_storage_val_converters.h | 4 +- contrib/epee/include/string_tools.h | 11 ++---- contrib/epee/src/mlog.cpp | 4 ++ contrib/epee/src/net_utils_base.cpp | 30 ++++++++++++++ contrib/epee/src/readline_buffer.cpp | 1 + contrib/epee/src/string_tools.cpp | 12 ++++++ src/blockchain_db/berkeleydb/db_bdb.h | 2 +- src/blockchain_db/blockchain_db.cpp | 1 + src/blockchain_db/blockchain_db.h | 2 +- src/blockchain_db/lmdb/db_lmdb.cpp | 1 + src/blockchain_db/lmdb/db_lmdb.h | 2 +- .../blockchain_import.cpp | 1 + src/blockchain_utilities/blocksdat_file.h | 3 +- src/blockchain_utilities/bootstrap_file.h | 3 +- src/checkpoints/checkpoints.cpp | 27 ++++++++++++- src/checkpoints/checkpoints.h | 28 +------------ src/common/boost_serialization_helper.h | 1 + src/common/dns_utils.cpp | 2 + src/common/perf_timer.cpp | 39 ++++++++++++++++++- src/common/perf_timer.h | 36 +---------------- src/common/stack_trace.cpp | 1 + src/common/updates.cpp | 1 + src/common/util.cpp | 1 + .../blobdatatype.h | 0 .../cryptonote_format_utils.cpp | 2 + .../cryptonote_format_utils.h | 2 +- src/cryptonote_basic/miner.cpp | 5 ++- src/cryptonote_core/cryptonote_core.cpp | 3 ++ src/cryptonote_core/cryptonote_core.h | 1 - src/cryptonote_core/cryptonote_tx_utils.cpp | 1 + src/cryptonote_protocol/block_queue.cpp | 1 + .../cryptonote_protocol_defs.h | 2 +- src/daemon/CMakeLists.txt | 1 - src/daemon/command_server.cpp | 2 + src/daemon/daemon.cpp | 1 + src/daemon/executor.h | 1 - src/debug_utilities/cn_deserialize.cpp | 1 + src/p2p/p2p_protocol_defs.h | 2 + src/ringct/rctOps.cpp | 1 + src/rpc/core_rpc_server.cpp | 1 + src/rpc/daemon_handler.cpp | 2 +- src/rpc/rpc_args.cpp | 1 + src/serialization/json_object.h | 1 + src/wallet/wallet2.cpp | 7 +++- src/wallet/wallet2.h | 2 - src/wallet/wallet_args.cpp | 1 + tests/functional_tests/main.cpp | 1 + tests/fuzz/block.cpp | 2 +- tests/fuzz/cold-outputs.cpp | 2 +- tests/fuzz/cold-transaction.cpp | 2 +- tests/fuzz/fuzzer.cpp | 1 + tests/fuzz/signature.cpp | 2 +- tests/fuzz/transaction.cpp | 2 +- tests/performance_tests/cn_slow_hash.h | 1 + tests/unit_tests/blockchain_db.cpp | 1 + tests/unit_tests/http.cpp | 1 + tests/unit_tests/main.cpp | 4 +- 73 files changed, 212 insertions(+), 161 deletions(-) rename src/{cryptonote_protocol => cryptonote_basic}/blobdatatype.h (100%) diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index 6d369d4d8..4ea3fa54b 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -27,6 +27,7 @@ #pragma once #include "misc_log_ex.h" +#include "string_tools.h" #include #include #include @@ -37,6 +38,8 @@ #include #endif #include +#include +#include #ifdef HAVE_READLINE #include "readline_buffer.h" diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index c387743a6..f037b4dd5 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -29,7 +29,8 @@ #define _FILE_IO_UTILS_H_ #include -#include +#include +#include namespace epee { @@ -63,7 +64,7 @@ namespace file_io_utils } inline - bool get_file_time(const std::string& path_to_file, OUT time_t& ft) + bool get_file_time(const std::string& path_to_file, time_t& ft) { boost::system::error_code ec; ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec); diff --git a/contrib/epee/include/math_helper.h b/contrib/epee/include/math_helper.h index 90398acbb..ef839f609 100644 --- a/contrib/epee/include/math_helper.h +++ b/contrib/epee/include/math_helper.h @@ -37,6 +37,7 @@ #include #include "misc_os_dependent.h" +#include "syncobj.h" namespace epee { diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 67fd93206..35ec0950b 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -28,26 +28,7 @@ #ifndef _MISC_LOG_EX_H_ #define _MISC_LOG_EX_H_ -#include "static_initializer.h" -#include "string_tools.h" -#include "time_helper.h" -#include "misc_os_dependent.h" - -#include "syncobj.h" - -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #include "easylogging++.h" diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h index 69ded09e5..81cecf714 100644 --- a/contrib/epee/include/misc_os_dependent.h +++ b/contrib/epee/include/misc_os_dependent.h @@ -42,6 +42,9 @@ #include #endif +#include +#include + #pragma once namespace epee { diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index d77c84c28..1a9d5d064 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -50,6 +50,7 @@ #include "http_auth.h" #include "to_nonconst_iterator.h" #include "net_parse_helpers.h" +#include "syncobj.h" //#include "shlwapi.h" diff --git a/contrib/epee/include/net/http_client_base.h b/contrib/epee/include/net/http_client_base.h index f5fb57d03..c3da28718 100644 --- a/contrib/epee/include/net/http_client_base.h +++ b/contrib/epee/include/net/http_client_base.h @@ -38,8 +38,8 @@ namespace epee virtual ~i_sub_handler(){} virtual bool update_in( std::string& piece_of_transfer)=0; - virtual void stop(std::string& OUT collect_remains)=0; - virtual bool update_and_stop(std::string& OUT collect_remains, bool& is_changed) + virtual void stop(std::string& collect_remains)=0; + virtual bool update_and_stop(std::string& collect_remains, bool& is_changed) { is_changed = true; bool res = this->update_in(collect_remains); @@ -66,7 +66,7 @@ namespace epee { return m_powner_filter->handle_target_data(piece_of_transfer); } - virtual void stop(std::string& OUT collect_remains) + virtual void stop(std::string& collect_remains) { } diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index 7ad6d198b..7b526e4e7 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -35,6 +35,8 @@ #include "levin_base.h" #include "misc_language.h" +#include "syncobj.h" +#include "misc_os_dependent.h" #include #include diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index ee0e13fc1..2c2efcd82 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -31,23 +31,16 @@ //#include //#include -#include -#include -#include -#include #include #include #include #include #include -#include #include #include #include #include "net/net_utils_base.h" #include "misc_language.h" -//#include "profile_tools.h" -#include "../string_tools.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "net" diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index 04e3fe6a4..7615786be 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -29,13 +29,11 @@ #ifndef _NET_UTILS_BASE_H_ #define _NET_UTILS_BASE_H_ -#include #include -#include +#include #include #include #include "serialization/keyvalue_serialization.h" -#include "string_tools.h" #include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -45,7 +43,6 @@ #define MAKE_IP( a1, a2, a3, a4 ) (a1|(a2<<8)|(a3<<16)|(a4<<24)) #endif - namespace epee { namespace net_utils @@ -214,19 +211,8 @@ namespace net_utils inline bool operator>=(const network_address& lhs, const network_address& rhs) { return !lhs.less(rhs); } - inline bool create_network_address(network_address &address, const std::string &string, uint16_t default_port = 0) - { - uint32_t ip; - uint16_t port; - if (epee::string_tools::parse_peer_from_string(ip, port, string)) - { - if (default_port && !port) - port = default_port; - address = ipv4_network_address{ip, port}; - return true; - } - return false; - } + bool create_network_address(network_address &address, const std::string &string, uint16_t default_port = 0); + /************************************************************************/ /* */ /************************************************************************/ @@ -309,21 +295,8 @@ namespace net_utils //some helpers - inline - std::string print_connection_context(const connection_context_base& ctx) - { - std::stringstream ss; - ss << ctx.m_remote_address.str() << " " << epee::string_tools::get_str_from_guid_a(ctx.m_connection_id) << (ctx.m_is_income ? " INC":" OUT"); - return ss.str(); - } - - inline - std::string print_connection_context_short(const connection_context_base& ctx) - { - std::stringstream ss; - ss << ctx.m_remote_address.str() << (ctx.m_is_income ? " INC":" OUT"); - return ss.str(); - } + std::string print_connection_context(const connection_context_base& ctx); + std::string print_connection_context_short(const connection_context_base& ctx); inline MAKE_LOGGABLE(connection_context_base, ct, os) { diff --git a/contrib/epee/include/profile_tools.h b/contrib/epee/include/profile_tools.h index f285fe48b..a0b5f77f4 100644 --- a/contrib/epee/include/profile_tools.h +++ b/contrib/epee/include/profile_tools.h @@ -28,6 +28,8 @@ #ifndef _PROFILE_TOOLS_H_ #define _PROFILE_TOOLS_H_ +#include "misc_os_dependent.h" + namespace epee { diff --git a/contrib/epee/include/readline_buffer.h b/contrib/epee/include/readline_buffer.h index cda7e34f9..87c8826cb 100644 --- a/contrib/epee/include/readline_buffer.h +++ b/contrib/epee/include/readline_buffer.h @@ -2,9 +2,7 @@ #include #include -#include #include -#include namespace rdln { diff --git a/contrib/epee/include/reg_exp_definer.h b/contrib/epee/include/reg_exp_definer.h index e2bed5c3f..eb11c9e10 100644 --- a/contrib/epee/include/reg_exp_definer.h +++ b/contrib/epee/include/reg_exp_definer.h @@ -29,7 +29,7 @@ #define _REG_EXP_DEFINER_H_ #include - +#include "syncobj.h" namespace epee { diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index 2e020b136..7087136cc 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -26,6 +26,13 @@ #pragma once +#include +#include +#include +#include +#include +#include + namespace epee { namespace serialization diff --git a/contrib/epee/include/storages/portable_storage_from_json.h b/contrib/epee/include/storages/portable_storage_from_json.h index 04b57376c..727f36552 100644 --- a/contrib/epee/include/storages/portable_storage_from_json.h +++ b/contrib/epee/include/storages/portable_storage_from_json.h @@ -25,6 +25,8 @@ // #pragma once +#include +#include #include "parserse_base_utils.h" #include "file_io_utils.h" diff --git a/contrib/epee/include/storages/portable_storage_to_bin.h b/contrib/epee/include/storages/portable_storage_to_bin.h index 38e9f9098..9501bbc2a 100644 --- a/contrib/epee/include/storages/portable_storage_to_bin.h +++ b/contrib/epee/include/storages/portable_storage_to_bin.h @@ -28,6 +28,7 @@ #pragma once +#include "pragma_comp_defs.h" #include "misc_language.h" #include "portable_storage_base.h" diff --git a/contrib/epee/include/storages/portable_storage_val_converters.h b/contrib/epee/include/storages/portable_storage_val_converters.h index f4a16cfae..52aa09eba 100644 --- a/contrib/epee/include/storages/portable_storage_val_converters.h +++ b/contrib/epee/include/storages/portable_storage_val_converters.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #include "misc_language.h" #include "portable_storage_base.h" @@ -146,7 +146,7 @@ POP_WARNINGS if(std::all_of(from.begin(), from.end(), ::isdigit)) to = boost::lexical_cast(from); // MyMonero ISO 8061 timestamp (2017-05-06T16:27:06Z) - else if (std::regex_match (from, std::regex("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\dZ"))) + else if (boost::regex_match (from, boost::regex("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\dZ"))) { // Convert to unix timestamp std::tm tm = {}; diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 25639263c..307323aa1 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -35,15 +35,15 @@ # include #endif +#include #include #include #include #include -#include #include #include #include -#include +#include #include "hex.h" #include "span.h" #include "warnings.h" @@ -350,11 +350,8 @@ POP_WARNINGS s = *(t_pod_type*)bin_buff.data(); return true; } - //---------------------------------------------------------------------------- - inline bool validate_hex(uint64_t length, const std::string& str) - { - return std::regex_match(str, std::regex("'^[0-9abcdefABCDEF]+$'")) && str.size() == length; - } + //---------------------------------------------------------------------------- + bool validate_hex(uint64_t length, const std::string& str); //---------------------------------------------------------------------------- inline std::string get_extension(const std::string& str) { diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 74b7dd2f4..a30efbc6a 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -28,7 +28,11 @@ #ifndef _MLOG_H_ #define _MLOG_H_ +#include #include +#include +#include +#include "string_tools.h" #include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY diff --git a/contrib/epee/src/net_utils_base.cpp b/contrib/epee/src/net_utils_base.cpp index 22afcf819..2f4015e81 100644 --- a/contrib/epee/src/net_utils_base.cpp +++ b/contrib/epee/src/net_utils_base.cpp @@ -1,5 +1,6 @@ #include "net/net_utils_base.h" +#include "string_tools.h" #include #include @@ -56,5 +57,34 @@ namespace epee { namespace net_utils if (typeid(*self_) != typeid(*other_self)) return false; return self_->is_same_host(*other_self); } + + bool create_network_address(network_address &address, const std::string &string, uint16_t default_port) + { + uint32_t ip; + uint16_t port; + if (epee::string_tools::parse_peer_from_string(ip, port, string)) + { + if (default_port && !port) + port = default_port; + address = ipv4_network_address{ip, port}; + return true; + } + return false; + } + + std::string print_connection_context(const connection_context_base& ctx) + { + std::stringstream ss; + ss << ctx.m_remote_address.str() << " " << epee::string_tools::get_str_from_guid_a(ctx.m_connection_id) << (ctx.m_is_income ? " INC":" OUT"); + return ss.str(); + } + + std::string print_connection_context_short(const connection_context_base& ctx) + { + std::stringstream ss; + ss << ctx.m_remote_address.str() << (ctx.m_is_income ? " INC":" OUT"); + return ss.str(); + } + }} diff --git a/contrib/epee/src/readline_buffer.cpp b/contrib/epee/src/readline_buffer.cpp index 291bba94c..00c2ddd62 100644 --- a/contrib/epee/src/readline_buffer.cpp +++ b/contrib/epee/src/readline_buffer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/contrib/epee/src/string_tools.cpp b/contrib/epee/src/string_tools.cpp index d04b16b75..fd0254016 100644 --- a/contrib/epee/src/string_tools.cpp +++ b/contrib/epee/src/string_tools.cpp @@ -26,6 +26,8 @@ #include "string_tools.h" +#include + #ifdef _WIN32 # include #else @@ -56,6 +58,16 @@ namespace string_tools return true; } + //---------------------------------------------------------------------------- + bool validate_hex(uint64_t length, const std::string& str) + { + if (str.size() != length) + return false; + for (char c: str) + if (!isxdigit(c)) + return false; + return true; + } } } diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index a040a70ef..dd78d951f 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -28,7 +28,7 @@ #include #include "blockchain_db/blockchain_db.h" -#include "cryptonote_protocol/blobdatatype.h" // for type blobdata +#include "cryptonote_basic/blobdatatype.h" // for type blobdata #include #include diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp index 2fb43a4ba..07b2451b0 100644 --- a/src/blockchain_db/blockchain_db.cpp +++ b/src/blockchain_db/blockchain_db.cpp @@ -28,6 +28,7 @@ #include +#include "string_tools.h" #include "blockchain_db.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "profile_tools.h" diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 79676b808..88034a927 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -36,7 +36,7 @@ #include #include "common/command_line.h" #include "crypto/hash.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/difficulty.h" #include "cryptonote_basic/hardfork.h" diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 865558e07..07a0e67b1 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -34,6 +34,7 @@ #include // memcpy #include +#include "string_tools.h" #include "common/util.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "crypto/crypto.h" diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index fce8f29ed..85b62b5db 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -29,7 +29,7 @@ #include #include "blockchain_db/blockchain_db.h" -#include "cryptonote_protocol/blobdatatype.h" // for type blobdata +#include "cryptonote_basic/blobdatatype.h" // for type blobdata #include "ringct/rctTypes.h" #include diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index a50b0bad6..70d1dd696 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "misc_log_ex.h" #include "bootstrap_file.h" #include "bootstrap_serialization.h" diff --git a/src/blockchain_utilities/blocksdat_file.h b/src/blockchain_utilities/blocksdat_file.h index d43811772..3fa3ee29e 100644 --- a/src/blockchain_utilities/blocksdat_file.h +++ b/src/blockchain_utilities/blocksdat_file.h @@ -31,8 +31,9 @@ #include #include #include - #include +#include +#include #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_boost_serialization.h" diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h index 0926ee2e5..63914dc26 100644 --- a/src/blockchain_utilities/bootstrap_file.h +++ b/src/blockchain_utilities/bootstrap_file.h @@ -31,8 +31,9 @@ #include #include #include - #include +#include +#include #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_core/blockchain.h" diff --git a/src/checkpoints/checkpoints.cpp b/src/checkpoints/checkpoints.cpp index 9be08958c..c66c4f5d6 100644 --- a/src/checkpoints/checkpoints.cpp +++ b/src/checkpoints/checkpoints.cpp @@ -36,15 +36,38 @@ using namespace epee; #include "common/dns_utils.h" #include "include_base_utils.h" +#include "string_tools.h" #include "storages/portable_storage_template_helper.h" // epee json include -#include -#include +#include "serialization/keyvalue_serialization.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "checkpoints" namespace cryptonote { + /** + * @brief struct for loading a checkpoint from json + */ + struct t_hashline + { + uint64_t height; //!< the height of the checkpoint + std::string hash; //!< the hash for the checkpoint + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(height) + KV_SERIALIZE(hash) + END_KV_SERIALIZE_MAP() + }; + + /** + * @brief struct for loading many checkpoints from json + */ + struct t_hash_json { + std::vector hashlines; //!< the checkpoint lines from the file + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(hashlines) + END_KV_SERIALIZE_MAP() + }; + //--------------------------------------------------------------------------- checkpoints::checkpoints() { diff --git a/src/checkpoints/checkpoints.h b/src/checkpoints/checkpoints.h index a643c5790..3e034f6f0 100644 --- a/src/checkpoints/checkpoints.h +++ b/src/checkpoints/checkpoints.h @@ -33,7 +33,6 @@ #include #include "misc_log_ex.h" #include "crypto/hash.h" -#include "serialization/keyvalue_serialization.h" #define ADD_CHECKPOINT(h, hash) CHECK_AND_ASSERT(add_checkpoint(h, hash), false); #define JSON_HASH_FILE_NAME "checkpoints.json" @@ -187,32 +186,7 @@ namespace cryptonote bool load_checkpoints_from_dns(bool testnet = false); private: - - - /** - * @brief struct for loading a checkpoint from json - */ - struct t_hashline - { - uint64_t height; //!< the height of the checkpoint - std::string hash; //!< the hash for the checkpoint - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(height) - KV_SERIALIZE(hash) - END_KV_SERIALIZE_MAP() - }; - - /** - * @brief struct for loading many checkpoints from json - */ - struct t_hash_json { - std::vector hashlines; //!< the checkpoint lines from the file - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(hashlines) - END_KV_SERIALIZE_MAP() - }; - std::map m_points; //!< the checkpoints container - }; + } diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h index 4a503d830..f8b21c52e 100644 --- a/src/common/boost_serialization_helper.h +++ b/src/common/boost_serialization_helper.h @@ -33,6 +33,7 @@ #include #include #include +#include namespace tools diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index f549218cb..d942ae9d0 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -34,6 +34,8 @@ #include "include_base_utils.h" #include #include +#include +#include using namespace epee; namespace bf = boost::filesystem; diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp index 3b68485d9..4947058d3 100644 --- a/src/common/perf_timer.cpp +++ b/src/common/perf_timer.cpp @@ -26,6 +26,8 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include +#include "misc_os_dependent.h" #include "perf_timer.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -35,7 +37,8 @@ namespace tools { el::Level performance_timer_log_level = el::Level::Debug; -__thread std::vector *performance_timers = NULL; + +static __thread std::vector *performance_timers = NULL; void set_performance_timer_log_level(el::Level level) { @@ -48,4 +51,38 @@ void set_performance_timer_log_level(el::Level level) performance_timer_log_level = level; } +PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Level l): name(s), unit(unit), level(l), started(false) +{ + ticks = epee::misc_utils::get_ns_count(); + if (!performance_timers) + { + MLOG(level, "PERF ----------"); + performance_timers = new std::vector(); + } + else + { + PerformanceTimer *pt = performance_timers->back(); + if (!pt->started) + { + MLOG(pt->level, "PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name); + pt->started = true; + } + } + performance_timers->push_back(this); +} + +PerformanceTimer::~PerformanceTimer() +{ + performance_timers->pop_back(); + ticks = epee::misc_utils::get_ns_count() - ticks; + char s[12]; + snprintf(s, sizeof(s), "%8llu ", (unsigned long long)ticks / (1000000000 / unit)); + MLOG(level, "PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name); + if (performance_timers->empty()) + { + delete performance_timers; + performance_timers = NULL; + } +} + } diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h index 4d7d99afb..a1d71609c 100644 --- a/src/common/perf_timer.h +++ b/src/common/perf_timer.h @@ -41,44 +41,12 @@ namespace tools class PerformanceTimer; extern el::Level performance_timer_log_level; -extern __thread std::vector *performance_timers; class PerformanceTimer { public: - PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug): name(s), unit(unit), level(l), started(false) - { - ticks = epee::misc_utils::get_ns_count(); - if (!performance_timers) - { - MLOG(level, "PERF ----------"); - performance_timers = new std::vector(); - } - else - { - PerformanceTimer *pt = performance_timers->back(); - if (!pt->started) - { - MLOG(pt->level, "PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name); - pt->started = true; - } - } - performance_timers->push_back(this); - } - - ~PerformanceTimer() - { - performance_timers->pop_back(); - ticks = epee::misc_utils::get_ns_count() - ticks; - char s[12]; - snprintf(s, sizeof(s), "%8llu ", (unsigned long long)ticks / (1000000000 / unit)); - MLOG(level, "PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name); - if (performance_timers->empty()) - { - delete performance_timers; - performance_timers = NULL; - } - } + PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug); + ~PerformanceTimer(); private: std::string name; diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp index 6fdf4dd47..bcdf72b60 100644 --- a/src/common/stack_trace.cpp +++ b/src/common/stack_trace.cpp @@ -39,6 +39,7 @@ #ifndef STATICLIB #include #endif +#include #include "common/stack_trace.h" #include "misc_log_ex.h" diff --git a/src/common/updates.cpp b/src/common/updates.cpp index 141330c2c..eff6754af 100644 --- a/src/common/updates.cpp +++ b/src/common/updates.cpp @@ -26,6 +26,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include #include "misc_log_ex.h" #include "util.h" #include "dns_utils.h" diff --git a/src/common/util.cpp b/src/common/util.cpp index de19fec81..d9e12ffe4 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -54,6 +54,7 @@ using namespace epee; #include #endif #include +#include #include #include diff --git a/src/cryptonote_protocol/blobdatatype.h b/src/cryptonote_basic/blobdatatype.h similarity index 100% rename from src/cryptonote_protocol/blobdatatype.h rename to src/cryptonote_basic/blobdatatype.h diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 6759f1826..a22c3bdea 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -32,7 +32,9 @@ using namespace epee; #include +#include #include "wipeable_string.h" +#include "string_tools.h" #include "cryptonote_format_utils.h" #include "cryptonote_config.h" #include "crypto/crypto.h" diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h index 714d80195..cabdb1f5c 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.h +++ b/src/cryptonote_basic/cryptonote_format_utils.h @@ -29,7 +29,7 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once -#include "cryptonote_protocol/cryptonote_protocol_defs.h" +#include "blobdatatype.h" #include "cryptonote_basic_impl.h" #include "account.h" #include "subaddress_index.h" diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index c90ab0f03..670baea50 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -32,14 +32,17 @@ #include #include #include +#include #include -#include "misc_language.h" #include "include_base_utils.h" +#include "misc_language.h" +#include "syncobj.h" #include "cryptonote_basic_impl.h" #include "cryptonote_format_utils.h" #include "file_io_utils.h" #include "common/command_line.h" #include "string_coding.h" +#include "string_tools.h" #include "storages/portable_storage_template_helper.h" #include "boost/logic/tribool.hpp" diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 04f1e46a7..8985c11ca 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -28,7 +28,10 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +#include + #include "include_base_utils.h" +#include "string_tools.h" using namespace epee; #include diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 6cb4fc938..1b60f83f0 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -36,7 +36,6 @@ #include #include -#include "p2p/net_node_common.h" #include "cryptonote_protocol/cryptonote_protocol_handler_common.h" #include "storages/portable_storage_template_helper.h" #include "common/download.h" diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 4afa669fd..662420bef 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -30,6 +30,7 @@ #include #include "include_base_utils.h" +#include "string_tools.h" using namespace epee; #include "common/apply_permutation.h" diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp index 813167400..bfff35456 100644 --- a/src/cryptonote_protocol/block_queue.cpp +++ b/src/cryptonote_protocol/block_queue.cpp @@ -31,6 +31,7 @@ #include #include #include +#include "string_tools.h" #include "cryptonote_protocol_defs.h" #include "block_queue.h" diff --git a/src/cryptonote_protocol/cryptonote_protocol_defs.h b/src/cryptonote_protocol/cryptonote_protocol_defs.h index 7cf7e4a4d..fc2f4c343 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_defs.h +++ b/src/cryptonote_protocol/cryptonote_protocol_defs.h @@ -33,7 +33,7 @@ #include #include "serialization/keyvalue_serialization.h" #include "cryptonote_basic/cryptonote_basic.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" namespace cryptonote { diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 2f9c2b2f9..c8b5abec5 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -59,7 +59,6 @@ set(daemon_private_headers rpc_command_executor.h # cryptonote_protocol - ../cryptonote_protocol/blobdatatype.h ../cryptonote_protocol/cryptonote_protocol_defs.h ../cryptonote_protocol/cryptonote_protocol_handler.h ../cryptonote_protocol/cryptonote_protocol_handler.inl diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 7ff6b2bf3..ecf58e22c 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -26,8 +26,10 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include #include "cryptonote_config.h" #include "version.h" +#include "string_tools.h" #include "daemon/command_server.h" #undef MONERO_DEFAULT_LOG_CATEGORY diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index f8acf1357..3bc6ea392 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "misc_log_ex.h" #include "daemon/daemon.h" #include "rpc/daemon_handler.h" diff --git a/src/daemon/executor.h b/src/daemon/executor.h index 137e7209c..35c9e9b47 100644 --- a/src/daemon/executor.h +++ b/src/daemon/executor.h @@ -32,7 +32,6 @@ #include #include #include -#include #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "daemon" diff --git a/src/debug_utilities/cn_deserialize.cpp b/src/debug_utilities/cn_deserialize.cpp index 7235ef855..a59c04dc6 100644 --- a/src/debug_utilities/cn_deserialize.cpp +++ b/src/debug_utilities/cn_deserialize.cpp @@ -26,6 +26,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/tx_extra.h" #include "cryptonote_core/blockchain.h" diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index d49d83989..181854e8e 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -34,6 +34,8 @@ #include "serialization/keyvalue_serialization.h" #include "net/net_utils_base.h" #include "misc_language.h" +#include "string_tools.h" +#include "time_helper.h" #include "cryptonote_config.h" #ifdef ALLOW_DEBUG_COMMANDS #include "crypto/crypto.h" diff --git a/src/ringct/rctOps.cpp b/src/ringct/rctOps.cpp index 8e94b52b3..a7311482c 100644 --- a/src/ringct/rctOps.cpp +++ b/src/ringct/rctOps.cpp @@ -28,6 +28,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include #include "misc_log_ex.h" #include "rctOps.h" using namespace crypto; diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index c2206c89a..8abca43e4 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -29,6 +29,7 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include "include_base_utils.h" +#include "string_tools.h" using namespace epee; #include "core_rpc_server.h" diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp index 4d3fbf491..6643ce4e4 100644 --- a/src/rpc/daemon_handler.cpp +++ b/src/rpc/daemon_handler.cpp @@ -32,7 +32,7 @@ // but including here for clarity #include "cryptonote_core/cryptonote_core.h" #include "cryptonote_basic/cryptonote_format_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "ringct/rctSigs.h" namespace cryptonote diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp index e03c5472d..ce4070270 100644 --- a/src/rpc/rpc_args.cpp +++ b/src/rpc/rpc_args.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "common/command_line.h" #include "common/i18n.h" diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h index 5dca7b249..fc4f528b2 100644 --- a/src/serialization/json_object.h +++ b/src/serialization/json_object.h @@ -28,6 +28,7 @@ #pragma once +#include "string_tools.h" #include "rapidjson/document.h" #include "cryptonote_basic/cryptonote_basic.h" #include "rpc/message_data_structs.h" diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 59e759bfc..7b7e371a2 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -28,12 +28,15 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +#include #include #include #include #include #include -#include +#include +#include +#include #include "include_base_utils.h" using namespace epee; @@ -49,7 +52,7 @@ using namespace epee; #include "profile_tools.h" #include "crypto/crypto.h" #include "serialization/binary_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "mnemonics/electrum-words.h" #include "common/i18n.h" #include "common/util.h" diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index de1bed90c..be8315468 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -59,8 +59,6 @@ #include "common/password.h" #include "node_rpc_proxy.h" -#include - #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2" diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp index e665042d4..91162c4bc 100644 --- a/src/wallet/wallet_args.cpp +++ b/src/wallet/wallet_args.cpp @@ -28,6 +28,7 @@ #include "wallet/wallet_args.h" #include +#include #include #include "common/i18n.h" #include "common/util.h" diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index 35a0bb9bd..9fd24cc06 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -31,6 +31,7 @@ #include #include "include_base_utils.h" +#include "string_tools.h" using namespace epee; #include "common/command_line.h" diff --git a/tests/fuzz/block.cpp b/tests/fuzz/block.cpp index 03751fc14..ce8785cc3 100644 --- a/tests/fuzz/block.cpp +++ b/tests/fuzz/block.cpp @@ -28,7 +28,7 @@ #include "include_base_utils.h" #include "file_io_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "fuzzer.h" diff --git a/tests/fuzz/cold-outputs.cpp b/tests/fuzz/cold-outputs.cpp index e585b4b13..2785db05d 100644 --- a/tests/fuzz/cold-outputs.cpp +++ b/tests/fuzz/cold-outputs.cpp @@ -28,7 +28,7 @@ #include "include_base_utils.h" #include "file_io_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "wallet/wallet2.h" diff --git a/tests/fuzz/cold-transaction.cpp b/tests/fuzz/cold-transaction.cpp index 25a80fc68..f0b4b26d6 100644 --- a/tests/fuzz/cold-transaction.cpp +++ b/tests/fuzz/cold-transaction.cpp @@ -28,7 +28,7 @@ #include "include_base_utils.h" #include "file_io_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "wallet/wallet2.h" diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp index 756a8c847..ede3fcc40 100644 --- a/tests/fuzz/fuzzer.cpp +++ b/tests/fuzz/fuzzer.cpp @@ -28,6 +28,7 @@ #include #include "include_base_utils.h" +#include "string_tools.h" #include "common/command_line.h" #include "common/util.h" #include "fuzzer.h" diff --git a/tests/fuzz/signature.cpp b/tests/fuzz/signature.cpp index 42a8fa997..7ec4434e6 100644 --- a/tests/fuzz/signature.cpp +++ b/tests/fuzz/signature.cpp @@ -28,7 +28,7 @@ #include "include_base_utils.h" #include "file_io_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "wallet/wallet2.h" diff --git a/tests/fuzz/transaction.cpp b/tests/fuzz/transaction.cpp index 9e2b9f2cb..294676404 100644 --- a/tests/fuzz/transaction.cpp +++ b/tests/fuzz/transaction.cpp @@ -28,7 +28,7 @@ #include "include_base_utils.h" #include "file_io_utils.h" -#include "cryptonote_protocol/blobdatatype.h" +#include "cryptonote_basic/blobdatatype.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "fuzzer.h" diff --git a/tests/performance_tests/cn_slow_hash.h b/tests/performance_tests/cn_slow_hash.h index 7b04d5bcc..bf9eb7501 100644 --- a/tests/performance_tests/cn_slow_hash.h +++ b/tests/performance_tests/cn_slow_hash.h @@ -30,6 +30,7 @@ #pragma once +#include "string_tools.h" #include "crypto/crypto.h" #include "cryptonote_basic/cryptonote_basic.h" diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp index 5592106cb..4ccd9c1c8 100644 --- a/tests/unit_tests/blockchain_db.cpp +++ b/tests/unit_tests/blockchain_db.cpp @@ -35,6 +35,7 @@ #include "gtest/gtest.h" +#include "string_tools.h" #include "blockchain_db/blockchain_db.h" #include "blockchain_db/lmdb/db_lmdb.h" #ifdef BERKELEY_DB diff --git a/tests/unit_tests/http.cpp b/tests/unit_tests/http.cpp index 135c0984e..5e427f064 100644 --- a/tests/unit_tests/http.cpp +++ b/tests/unit_tests/http.cpp @@ -30,6 +30,7 @@ #include "net/http_auth.h" #include +#include #include #include #include diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp index 95ea67410..c0e143551 100644 --- a/tests/unit_tests/main.cpp +++ b/tests/unit_tests/main.cpp @@ -30,10 +30,12 @@ #include "gtest/gtest.h" -#include +#include +#include #include #include "include_base_utils.h" +#include "string_tools.h" #include "common/command_line.h" #include "common/util.h" #include "unit_tests_utils.h"