From a3dcb32834cbc0df686382e3a1c7520e183ac583 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 3 Jun 2021 15:15:05 +0300 Subject: [PATCH] more logs on chainshortener --- src/wallet/wallet2.cpp | 7 +++++++ src/wallet/wallet_chain_shortener.cpp | 17 +++++++++++++++++ src/wallet/wallet_chain_shortener.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index faa7f267..bf93de6a 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2667,6 +2667,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) if (wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_INITAL) { need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, data_file); + WLT_LOG_L0("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_INITAL(need_to_resync=" << need_to_resync << ")"); } else if (wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_2) { @@ -2675,6 +2676,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) in.push(decrypt_filter); in.push(data_file); need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, in); + WLT_LOG_L0("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_2(need_to_resync=" << need_to_resync << ")"); } else if(wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_3) { @@ -2683,6 +2685,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) in.push(decrypt_filter); in.push(data_file); need_to_resync = !tools::portable_unserialize_obj_from_stream2(*this, in); + WLT_LOG_L0("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_3(need_to_resync="<< need_to_resync <<")"); } else { @@ -2703,6 +2706,8 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) << ", file_size=" << m_current_wallet_file_size << ", blockchain_size: " << m_chain.get_blockchain_current_size() ); + WLT_LOG_L0("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text()); + WLT_LOG_L0("(after loading: pending_key_images: " << m_pending_key_images.size() << ", pki file elements: " << m_pending_key_images_file_container.size() << ", tx_keys: " << m_tx_keys.size() << ")"); @@ -2776,6 +2781,8 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor boost::uintmax_t tmp_file_size = boost::filesystem::file_size(tmp_file_path); WLT_LOG_L0("Stored successfully to temporary file " << tmp_file_path.string() << ", file size=" << tmp_file_size); + WLT_LOG_L0("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text()); + // for the sake of safety perform a double-renaming: wallet file -> old tmp, new tmp -> wallet file, remove old tmp boost::filesystem::path tmp_old_file_path = boost::filesystem::path(path_to_save); diff --git a/src/wallet/wallet_chain_shortener.cpp b/src/wallet/wallet_chain_shortener.cpp index 9d30cb5f..8633c40d 100644 --- a/src/wallet/wallet_chain_shortener.cpp +++ b/src/wallet/wallet_chain_shortener.cpp @@ -274,6 +274,23 @@ void wallet_chain_shortener::check_if_block_matched(uint64_t i, const crypto::ha } } //---------------------------------------------------------------------------------------------------- +std::string wallet_chain_shortener::get_internal_state_text() const +{ + std::stringstream ss; +#define PRINT_CHAIN_SHORTENER_STATE_INFO(cont_name) \ + if (cont_name.size()) \ + { \ + ss << #cont_name << ".size(): [" << cont_name.begin().first << ": " << cont_name.begin().second << "]" << ENDL; \ + } + + PRINT_CHAIN_SHORTENER_STATE_INFO(m_last_20_blocks); + PRINT_CHAIN_SHORTENER_STATE_INFO(m_last_144_blocks_every_10); + PRINT_CHAIN_SHORTENER_STATE_INFO(m_last_144_blocks_every_100); + PRINT_CHAIN_SHORTENER_STATE_INFO(m_last_144_blocks_every_1000); + ss << "m_local_bc_size = " << m_local_bc_size << ENDL; + return ss.str(); +} +//---------------------------------------------------------------------------------------------------- void clean_map_from_items_above(std::map& container, uint64_t height) { while (container.size() && (--container.end())->first >= height) diff --git a/src/wallet/wallet_chain_shortener.h b/src/wallet/wallet_chain_shortener.h index 2ea61366..500c2494 100644 --- a/src/wallet/wallet_chain_shortener.h +++ b/src/wallet/wallet_chain_shortener.h @@ -46,7 +46,7 @@ public: } //debug functions - + std::string get_internal_state_text() const; private: std::atomic m_local_bc_size; //temporary workaround crypto::hash m_genesis;