From 88073e300336b728cc4c07ec24bb21b6f0da6882 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 23 Sep 2019 21:51:25 +0200 Subject: [PATCH 1/8] added more logs + fixed issue with forgotten cumulative_diff_precise_adjusted --- src/currency_core/blockchain_storage.cpp | 15 ++++++++++++--- src/currency_core/blockchain_storage_basic.h | 1 + src/currency_core/currency_config.h | 2 +- src/daemon/daemon_commands_handler.h | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 54b2e8f4..68937caa 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1820,10 +1820,19 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ wide_difficulty_type main_pow_diff_begin = get_last_alt_x_block_cumulative_precise_adj_difficulty(alt_chain_type(), connection_point.height - 1, false); main_cumul_diff.pow_diff = main_pow_diff_end - main_pow_diff_begin; - //TODO: measurment of precise cumulative difficult + //TODO: measurement of precise cumulative difficult wide_difficulty_type alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff); wide_difficulty_type main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff); - + LOG_PRINT_L1("[FORK_CHOICE]: " << ENDL + << "difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL + << "difficulty_pos_at_split_point:" << difficulty_pos_at_split_point << ENDL + << "alt_cumul_diff.pow_diff:" << alt_cumul_diff.pow_diff << ENDL + << "alt_cumul_diff.pos_diff:" << alt_cumul_diff.pos_diff << ENDL + << "main_cumul_diff.pow_diff:" << main_cumul_diff.pow_diff << ENDL + << "main_cumul_diff.pos_diff:" << main_cumul_diff.pos_diff << ENDL + << "alt:" << alt << ENDL + << "main:" << main << ENDL + ); if (main < alt) return true; else if (main > alt) @@ -1838,7 +1847,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ if (std::memcmp(&main_chain_bei.stake_hash, &proof_alt, sizeof(main_chain_bei.stake_hash)) >= 0) return false; - LOG_PRINT_L2("[is_reorganize_required]:TRUE, \"by order of memcmp\" main_stake_hash:" << &main_chain_bei.stake_hash << ", alt_stake_hash" << proof_alt); + LOG_PRINT_L1("[is_reorganize_required]:TRUE, \"by order of memcmp\" main_stake_hash:" << &main_chain_bei.stake_hash << ", alt_stake_hash" << proof_alt); return true; } } diff --git a/src/currency_core/blockchain_storage_basic.h b/src/currency_core/blockchain_storage_basic.h index dd3cf354..7344f200 100644 --- a/src/currency_core/blockchain_storage_basic.h +++ b/src/currency_core/blockchain_storage_basic.h @@ -63,6 +63,7 @@ namespace currency FIELD(block_cumulative_size) FIELD(cumulative_diff_adjusted) FIELD(cumulative_diff_precise) + FIELD(cumulative_diff_precise_adjusted) FIELD(difficulty) FIELD(already_generated_coins) FIELD(stake_hash) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index af7ad918..fce54784 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -202,7 +202,7 @@ #define CURRENT_TRANSACTION_CHAIN_ENTRY_ARCHIVE_VER 3 #define CURRENT_BLOCK_EXTENDED_INFO_ARCHIVE_VER 1 -#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 8 +#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 9 #define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1 diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 391f16f4..593e9163 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -499,8 +499,15 @@ private: bool r = m_srv.get_payload_object().get_core().get_blockchain_storage().get_main_blocks_rpc_details(height, 1, false, blocks); if (r && blocks.size()) { + currency::block b = AUTO_VAL_INIT(b); + m_srv.get_payload_object().get_core().get_blockchain_storage().get_block_by_height(height, b); + currency::blobdata blob = block_to_blob(b); + std::string block_hex = epee::string_tools::buff_to_hex_nodelimer(blob); + currency::block_rpc_extended_info& rbei = blocks.back(); - LOG_PRINT_GREEN("------------------ block_id: " << rbei.id << " ------------------" << ENDL << epee::serialization::store_t_to_json(rbei), LOG_LEVEL_0); + LOG_PRINT_GREEN("------------------ block_id: " << rbei.id << " ------------------" << + ENDL << epee::serialization::store_t_to_json(rbei) << ENDL + << " ------------------ hex_blob: " << ENDL << block_hex, LOG_LEVEL_0); } else { @@ -523,8 +530,14 @@ private: if (r) { + currency::block b = AUTO_VAL_INIT(b); + m_srv.get_payload_object().get_core().get_blockchain_storage().get_block_by_hash(block_hash, b); + currency::blobdata blob = block_to_blob(b); + std::string block_hex = epee::string_tools::buff_to_hex_nodelimer(blob); // currency::block& block = bei.bl; - LOG_PRINT_GREEN("------------------ block_id: " << bei.id << " ------------------" << ENDL << epee::serialization::store_t_to_json(bei), LOG_LEVEL_0); + LOG_PRINT_GREEN("------------------ block_id: " << bei.id << " ------------------" << ENDL + << epee::serialization::store_t_to_json(bei) << ENDL + << " ------------------ hex_blob: " << ENDL << block_hex, LOG_LEVEL_0); } else { From 14bd668e9a3fcce22e86e8938ea2b9411748fd35 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 23 Sep 2019 23:12:44 +0300 Subject: [PATCH 2/8] === build number: 57 -> 58 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index b685d4a8..68442457 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -7,6 +7,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 57 +#define PROJECT_VERSION_BUILD_NO 58 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 8062faf9f05b0ead8d0c7069dbfb586da257ad96 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 23 Sep 2019 23:12:44 +0300 Subject: [PATCH 3/8] === build number: 57 -> 58 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index b685d4a8..68442457 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -7,6 +7,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 57 +#define PROJECT_VERSION_BUILD_NO 58 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 7706f0d6acded4fdf30a89fce7b50f37cb0c9517 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 24 Sep 2019 17:49:04 +0300 Subject: [PATCH 4/8] filesystem unicode support: WIP --- contrib/epee/include/file_io_utils.h | 17 ++++++++++------- contrib/epee/include/misc_log_ex.h | 15 +++++++++------ src/common/db_backend_lmdb.cpp | 4 ---- src/common/util.cpp | 26 ++++++++++++++++---------- src/currency_core/currency_core.cpp | 26 ++++++++++++++++++++++---- 5 files changed, 57 insertions(+), 31 deletions(-) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index 39a96942..8e5fa6fd 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -52,6 +52,7 @@ #endif #include "include_base_utils.h" +#include "string_coding.h" namespace epee { @@ -380,16 +381,18 @@ namespace file_io_utils typedef int native_filesystem_handle; #endif + // uses UTF-8 for unicode names for all systems inline bool open_and_lock_file(const std::string file_path, native_filesystem_handle& h_file) { #ifdef WIN32 - h_file = ::CreateFileA(file_path.c_str(), // name of the write - GENERIC_WRITE, // open for writing - 0, // do not share - NULL, // default security - OPEN_ALWAYS, // create new file only - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no attr. template + std::wstring file_path_w = epee::string_encoding::utf8_to_wstring(file_path); + h_file = ::CreateFileW(file_path_w.c_str(), // name of the file + GENERIC_WRITE, // open for writing + 0, // do not share + NULL, // default security + OPEN_ALWAYS, // create new file only + FILE_ATTRIBUTE_NORMAL, // normal file + NULL); // no attr. template if (h_file == INVALID_HANDLE_VALUE) return false; else diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 8f932e10..620ed3fb 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -65,6 +65,7 @@ DISABLE_VS_WARNINGS(4100) #include "syncobj.h" #include "sync_locked_object.h" +#include "string_coding.h" #define LOG_LEVEL_SILENT -1 @@ -696,11 +697,11 @@ namespace log_space public: typedef std::map named_log_streams; - file_output_stream( std::string default_log_file_name, std::string log_path ) + file_output_stream( const std::string& default_log_file_name, const std::string& log_path ) { m_default_log_filename = default_log_file_name; m_max_logfile_size = 0; - m_default_log_path = log_path; + m_default_log_path_w = epee::string_encoding::utf8_to_wstring(log_path); m_pdefault_file_stream = add_new_stream_and_open(default_log_file_name.c_str()); } @@ -718,20 +719,21 @@ namespace log_space } private: named_log_streams m_log_file_names; - std::string m_default_log_path; + std::wstring m_default_log_path_w; std::ofstream* m_pdefault_file_stream; std::string m_log_rotate_cmd; std::string m_default_log_filename; uint64_t m_max_logfile_size; + // gets utf-8 encoded string std::ofstream* add_new_stream_and_open(const char* pstream_name) { //log_space::rotate_log_file((m_default_log_path + "\\" + pstream_name).c_str()); boost::system::error_code ec; - boost::filesystem::create_directories(m_default_log_path, ec); + boost::filesystem::create_directories(m_default_log_path_w, ec); std::ofstream* pstream = (m_log_file_names[pstream_name] = new std::ofstream); - std::string target_path = m_default_log_path + "/" + pstream_name; + std::wstring target_path = m_default_log_path_w + L"/" + epee::string_encoding::utf8_to_wstring(pstream_name); pstream->open( target_path.c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */); if(pstream->fail()) return NULL; @@ -769,6 +771,7 @@ namespace log_space m_target_file_stream->write(buffer, buffer_len ); m_target_file_stream->flush(); + /* if(m_max_logfile_size) { std::ofstream::pos_type pt = m_target_file_stream->tellp(); @@ -823,7 +826,7 @@ namespace log_space return false; } } - + */ return true; } int get_type(){return LOGGER_FILE;} diff --git a/src/common/db_backend_lmdb.cpp b/src/common/db_backend_lmdb.cpp index fdb289ff..6c913f34 100644 --- a/src/common/db_backend_lmdb.cpp +++ b/src/common/db_backend_lmdb.cpp @@ -49,10 +49,6 @@ namespace tools CHECK_AND_ASSERT_MESS_LMDB_DB(res, false, "Unable to mdb_env_set_mapsize"); m_path = path_; -#ifdef WIN32 - m_path = epee::string_encoding::convert_ansii_to_utf8(m_path); -#endif - CHECK_AND_ASSERT_MES(tools::create_directories_if_necessary(m_path), false, "create_directories_if_necessary failed: " << m_path); res = mdb_env_open(m_penv, m_path.c_str(), MDB_NORDAHEAD , 0644); diff --git a/src/common/util.cpp b/src/common/util.cpp index 48fd7588..999c5401 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -24,6 +24,8 @@ using namespace epee; #include +#include "string_coding.h" + namespace tools { std::function signal_handler::m_handler; @@ -450,18 +452,22 @@ std::string get_nix_version_display_string() #ifdef WIN32 - std::string get_special_folder_path(int nfolder, bool iscreate) + std::wstring get_special_folder_path_w(int nfolder, bool iscreate) { - namespace fs = boost::filesystem; - char psz_path[MAX_PATH] = ""; + wchar_t psz_path[MAX_PATH] = L""; - if(SHGetSpecialFolderPathA(NULL, psz_path, nfolder, iscreate)) + if (SHGetSpecialFolderPathW(NULL, psz_path, nfolder, iscreate)) { return psz_path; } - LOG_ERROR("SHGetSpecialFolderPathA() failed, could not obtain requested path."); - return ""; + LOG_ERROR("SHGetSpecialFolderPathW(" << nfolder << ", " << iscreate << ") failed, could not obtain requested path."); + return L""; + } + + std::string get_special_folder_path_utf8(int nfolder, bool iscreate) + { + return epee::string_encoding::wstring_to_utf8(get_special_folder_path_w(nfolder, iscreate)); } #endif @@ -476,9 +482,9 @@ std::string get_nix_version_display_string() #ifdef WIN32 // Windows #ifdef _M_X64 - config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT; + config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT; #else - config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT + "-x86"; + config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT + "-x86"; #endif #else std::string pathRet; @@ -518,7 +524,7 @@ std::string get_nix_version_display_string() std::string wallets_dir; #ifdef WIN32 // Windows - wallets_dir = get_special_folder_path(CSIDL_PERSONAL, true) + "/" + CURRENCY_NAME_BASE; + wallets_dir = get_special_folder_path_utf8(CSIDL_PERSONAL, true) + "/" + CURRENCY_NAME_BASE; #else std::string pathRet; char* pszHome = getenv("HOME"); @@ -553,7 +559,7 @@ std::string get_nix_version_display_string() { namespace fs = boost::filesystem; boost::system::error_code ec; - fs::path fs_path(path); + fs::path fs_path = epee::string_encoding::utf8_to_wstring(path); if (fs::is_directory(fs_path, ec)) { return true; diff --git a/src/currency_core/currency_core.cpp b/src/currency_core/currency_core.cpp index 54b93443..a79dfb2a 100644 --- a/src/currency_core/currency_core.cpp +++ b/src/currency_core/currency_core.cpp @@ -18,6 +18,7 @@ using namespace epee; #include "currency_core/currency_config.h" #include "currency_format_utils.h" #include "misc_language.h" +#include "string_coding.h" #define MINIMUM_REQUIRED_FREE_SPACE_BYTES (1024 * 1024 * 100) @@ -717,10 +718,27 @@ namespace currency //----------------------------------------------------------------------------------------------- bool core::check_if_free_space_critically_low(uint64_t* p_available_space /* = nullptr */) { - boost::filesystem::space_info si = boost::filesystem::space(m_config_folder); - if (p_available_space != nullptr) - *p_available_space = si.available; - return si.available < MINIMUM_REQUIRED_FREE_SPACE_BYTES; + namespace fs = boost::filesystem; + + try + { + CHECK_AND_ASSERT_MES(tools::create_directories_if_necessary(m_config_folder), false, "create_directories_if_necessary failed: " << m_config_folder); + std::wstring config_folder_w = epee::string_encoding::utf8_to_wstring(m_config_folder); + fs::space_info si = fs::space(config_folder_w); + if (p_available_space != nullptr) + *p_available_space = si.available; + return si.available < MINIMUM_REQUIRED_FREE_SPACE_BYTES; + } + catch (std::exception& e) + { + LOG_ERROR("failed to determine free space: " << e.what()); + return false; + } + catch (...) + { + LOG_ERROR("failed to determine free space: unknown exception"); + return false; + } } void core::check_free_space() From 20a81cbe6dd61a960cb7763816e3c61f1b49460a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 24 Sep 2019 17:19:43 +0200 Subject: [PATCH 5/8] fixed warnings --- contrib/CMakeLists.txt | 5 ++--- contrib/db/liblmdb/CMakeLists.txt | 2 +- contrib/epee/include/net/abstract_tcp_server2.inl | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index c1ea6bdd..f691d096 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -12,10 +12,9 @@ set_property(TARGET zlibstatic PROPERTY FOLDER "contrib") set_property(TARGET lmdb PROPERTY FOLDER "contrib") - - if(MSVC) set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") else() - set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") + set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") + set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") endif() diff --git a/contrib/db/liblmdb/CMakeLists.txt b/contrib/db/liblmdb/CMakeLists.txt index 4a60e07c..8ec1a8d8 100644 --- a/contrib/db/liblmdb/CMakeLists.txt +++ b/contrib/db/liblmdb/CMakeLists.txt @@ -4,7 +4,7 @@ set (lmdb_sources mdb.c midl.c) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable") endif() if(FREEBSD) add_definitions(-DMDB_DSYNC=O_SYNC) diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index e0fcc3b1..4953508d 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -475,7 +475,7 @@ bool boosted_tcp_server::init_server(uint32_t port, const st } //----------------------------------------------------------------------------- PUSH_WARNINGS -DISABLE_GCC_WARNING(maybe - uninitialized) +DISABLE_GCC_WARNING(maybe-uninitialized) template bool boosted_tcp_server::init_server(const std::string port, const std::string& address) { From d0ea59aebc4d12f8dab08cd7161e4821d61edb16 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 24 Sep 2019 18:30:25 +0200 Subject: [PATCH 6/8] removed more warnings, code cleanup --- contrib/db/liblmdb/CMakeLists.txt | 2 +- src/simplewallet/simplewallet.cpp | 5 ----- src/wallet/wallet2.cpp | 18 +++++++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/contrib/db/liblmdb/CMakeLists.txt b/contrib/db/liblmdb/CMakeLists.txt index 8ec1a8d8..dc491820 100644 --- a/contrib/db/liblmdb/CMakeLists.txt +++ b/contrib/db/liblmdb/CMakeLists.txt @@ -4,7 +4,7 @@ set (lmdb_sources mdb.c midl.c) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable -Wno-implicit-fallthrough -Wno-maybe-uninitialized ") endif() if(FREEBSD) add_definitions(-DMDB_DSYNC=O_SYNC) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 45c77b65..db6e604f 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -154,11 +154,6 @@ namespace return message_writer(color ? epee::log_space::console_color_green : epee::log_space::console_color_default, false, std::string(), LOG_LEVEL_2); } - message_writer success_msg_writer(epee::log_space::console_colors color) - { - return message_writer(color, true, std::string(), LOG_LEVEL_2); - } - message_writer fail_msg_writer() { return message_writer(epee::log_space::console_color_red, true, "Error: ", LOG_LEVEL_0); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 15a36e4d..3bb392c3 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1890,7 +1890,7 @@ void wallet2::load_keys2ki(bool create_if_not_exist, bool& need_to_resync) m_pending_key_images.clear(); for (size_t i = 0, size = m_pending_key_images_file_container.size(); i < size; ++i) { - out_key_to_ki item = AUTO_VAL_INIT(item); + out_key_to_ki item = AUTO_VAL_INIT_T(out_key_to_ki); ok = m_pending_key_images_file_container.get_item(i, item); WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(ok, "m_pending_key_images_file_container.get_item() failed for index " << i << ", size: " << m_pending_key_images_file_container.size()); ok = m_pending_key_images.insert(std::make_pair(item.out_key, item.key_image)).second; @@ -4002,7 +4002,7 @@ void wallet2::prepare_transaction(const construct_tx_param& ctp, finalize_tx_par //---------------------------------------------------------------------------------------------------- void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::transaction& tx, crypto::secret_key& tx_key, bool broadcast_tx) { - TIME_MEASURE_START_MS(construct_tx_time); + //TIME_MEASURE_START_MS(construct_tx_time); bool r = currency::construct_tx(m_account.get_keys(), ftp.sources, ftp.prepared_destinations, @@ -4016,10 +4016,10 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans ftp.tx_outs_attr, ftp.shuffle, ftp.flags); - TIME_MEASURE_FINISH_MS(construct_tx_time); + //TIME_MEASURE_FINISH_MS(construct_tx_time); THROW_IF_FALSE_WALLET_EX(r, error::tx_not_constructed, ftp.sources, ftp.prepared_destinations, ftp.unlock_time); - TIME_MEASURE_START_MS(sign_ms_input_time); + //TIME_MEASURE_START_MS(sign_ms_input_time); if (ftp.multisig_id != currency::null_hash) { // In case there's multisig input is used -- sign it partially with this wallet's keys (we don't have any others here). @@ -4031,21 +4031,21 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans r = sign_multisig_input_in_tx(tx, 0, m_account.get_keys(), ms_source_tx, &is_tx_input_fully_signed); // it's assumed that ms input is the first one (index 0) WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r && !is_tx_input_fully_signed, "sign_multisig_input_in_tx failed: r = " << r << ", is_tx_input_fully_signed = " << is_tx_input_fully_signed); } - TIME_MEASURE_FINISH_MS(sign_ms_input_time); + //TIME_MEASURE_FINISH_MS(sign_ms_input_time); m_tx_keys.insert(std::make_pair(get_transaction_hash(tx), tx_key)); THROW_IF_FALSE_WALLET_EX(get_object_blobsize(tx) < CURRENCY_MAX_TRANSACTION_BLOB_SIZE, error::tx_too_big, tx, m_upper_transaction_size_limit); - TIME_MEASURE_START(send_transaction_to_network_time); + //TIME_MEASURE_START(send_transaction_to_network_time); if (broadcast_tx) send_transaction_to_network(tx); - TIME_MEASURE_FINISH(send_transaction_to_network_time); + //TIME_MEASURE_FINISH(send_transaction_to_network_time); - TIME_MEASURE_START(add_sent_tx_detailed_info_time); + //TIME_MEASURE_START(add_sent_tx_detailed_info_time); if (broadcast_tx) add_sent_tx_detailed_info(tx, ftp.prepared_destinations, ftp.selected_transfers); - TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); + //TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); /* TODO WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms" From ceb1739f236dfbfdccf945c3ad1d9fde66921f9a Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 25 Sep 2019 06:22:00 +0300 Subject: [PATCH 7/8] filesystem unicode support: WIP2 --- contrib/epee/include/misc_log_ex.h | 16 +++++++++------- src/daemon/daemon.cpp | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 620ed3fb..00a4c9ff 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -695,7 +695,7 @@ namespace log_space class file_output_stream : public ibase_log_stream { public: - typedef std::map named_log_streams; + typedef std::map named_log_streams; file_output_stream( const std::string& default_log_file_name, const std::string& log_path ) { @@ -720,20 +720,21 @@ namespace log_space private: named_log_streams m_log_file_names; std::wstring m_default_log_path_w; - std::ofstream* m_pdefault_file_stream; + boost::filesystem::ofstream* m_pdefault_file_stream; std::string m_log_rotate_cmd; std::string m_default_log_filename; uint64_t m_max_logfile_size; // gets utf-8 encoded string - std::ofstream* add_new_stream_and_open(const char* pstream_name) + boost::filesystem::ofstream* add_new_stream_and_open(const char* pstream_name) { //log_space::rotate_log_file((m_default_log_path + "\\" + pstream_name).c_str()); boost::system::error_code ec; boost::filesystem::create_directories(m_default_log_path_w, ec); - std::ofstream* pstream = (m_log_file_names[pstream_name] = new std::ofstream); + boost::filesystem::ofstream* pstream = (m_log_file_names[pstream_name] = new boost::filesystem::ofstream); std::wstring target_path = m_default_log_path_w + L"/" + epee::string_encoding::utf8_to_wstring(pstream_name); + pstream->open( target_path.c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */); if(pstream->fail()) return NULL; @@ -756,7 +757,7 @@ namespace log_space virtual bool out_buffer( const char* buffer, int buffer_len, int log_level, int color, const char* plog_name = NULL ) { - std::ofstream* m_target_file_stream = m_pdefault_file_stream; + boost::filesystem::ofstream* m_target_file_stream = m_pdefault_file_stream; if(plog_name) { //find named stream named_log_streams::iterator it = m_log_file_names.find(plog_name); @@ -774,7 +775,7 @@ namespace log_space /* if(m_max_logfile_size) { - std::ofstream::pos_type pt = m_target_file_stream->tellp(); + boost::filesystem::ofstream::pos_type pt = m_target_file_stream->tellp(); uint64_t current_sz = pt; if(current_sz > m_max_logfile_size) { @@ -821,7 +822,8 @@ namespace log_space misc_utils::call_sys_cmd(m_log_rotate_cmd_local_copy); } - m_target_file_stream->open( (m_default_log_path + "/" + log_file_name).c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */); + + m_target_file_stream->open( (m_default_log_path + "/" + log_file_name).c_str(), std::ios_base::out | std::ios::app / * ios_base::trunc * /); if(m_target_file_stream->fail()) return false; } diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index f41affd6..a9ab511d 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -122,6 +122,21 @@ int main(int argc, char* argv[]) // setup custom terminate functions std::set_terminate(&terminate_handler_func); + //// + + std::string utf8_str = "\xd0\x92\xd0\xb0\xd1\x81\xd0\xb8\xd1\x81\xd1\x83\xd0\xb0\xd0\xbb\xd0\xb8\xd1\x9d"; + + boost::system::error_code ec; + + boost::filesystem::create_directory(boost::filesystem::path(epee::string_encoding::utf8_to_wstring(std::string("utf8_to_wstring_") + utf8_str)), ec); + std::cout << "utf8_to_wstring: ec = " << ec << std::endl; + + boost::filesystem::create_directory(boost::filesystem::path(std::string("utf8_") + utf8_str), ec); + std::cout << "utf8: ec = " << ec << std::endl; + + return 0; + + //// po::options_description desc_cmd_only("Command line options"); po::options_description desc_cmd_sett("Command line options and settings options", 130, 83); From 283994e6cd077aeaaeee15422cbd3f2e9439a0e0 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 25 Sep 2019 07:33:53 +0300 Subject: [PATCH 8/8] removed temp test --- src/daemon/daemon.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index a9ab511d..f41affd6 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -122,21 +122,6 @@ int main(int argc, char* argv[]) // setup custom terminate functions std::set_terminate(&terminate_handler_func); - //// - - std::string utf8_str = "\xd0\x92\xd0\xb0\xd1\x81\xd0\xb8\xd1\x81\xd1\x83\xd0\xb0\xd0\xbb\xd0\xb8\xd1\x9d"; - - boost::system::error_code ec; - - boost::filesystem::create_directory(boost::filesystem::path(epee::string_encoding::utf8_to_wstring(std::string("utf8_to_wstring_") + utf8_str)), ec); - std::cout << "utf8_to_wstring: ec = " << ec << std::endl; - - boost::filesystem::create_directory(boost::filesystem::path(std::string("utf8_") + utf8_str), ec); - std::cout << "utf8: ec = " << ec << std::endl; - - return 0; - - //// po::options_description desc_cmd_only("Command line options"); po::options_description desc_cmd_sett("Command line options and settings options", 130, 83);