diff --git a/src/common/db_backend_selector.cpp b/src/common/db_backend_selector.cpp index 9c7917ca..33f1382f 100644 --- a/src/common/db_backend_selector.cpp +++ b/src/common/db_backend_selector.cpp @@ -67,6 +67,19 @@ namespace db return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX; } + std::string db_backend_selector::get_db_folder_path_old_1() const + { + //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); + return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1; + } + + std::string db_backend_selector::get_db_folder_path_old_2() const + { + //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); + return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2; + } + + std::string db_backend_selector::get_temp_db_folder_path() const { //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); diff --git a/src/common/db_backend_selector.h b/src/common/db_backend_selector.h index b9d811b8..54c4a10a 100644 --- a/src/common/db_backend_selector.h +++ b/src/common/db_backend_selector.h @@ -34,6 +34,9 @@ namespace tools std::shared_ptr create_backend(); + std::string get_db_folder_path_old_1() const; + std::string get_db_folder_path_old_2() const; + private: db_engine_type m_engine_type; std::string m_config_folder; diff --git a/src/common/pre_download.h b/src/common/pre_download.h index 9314c059..102c65bd 100644 --- a/src/common/pre_download.h +++ b/src/common/pre_download.h @@ -21,8 +21,8 @@ namespace tools }; #ifndef TESTNET - static constexpr pre_download_entry c_pre_download_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3030303.pak", "937c80a2a212e70f0b5c9001159f983db72dd0cf7a6d55d72bcd9d6998874ffb", 7809031729, 12347842560 }; - static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3030303.pak", "227f20b3998a8622363ebd4b7189e73caac21cfc17fa8544a3fa9d593e41709d", 9450752666, 12102598656 }; + static constexpr pre_download_entry c_pre_download_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3083770.pak", "e7cb7b5e1560c3a7615604880feda9df37636be83264a5afff01f44b5f824cc8", 8357805798, 12884705280 }; + static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3083770.pak", "685db01e1a4c827d20e777563009f771be593fe80cc32b8a4dfe2711e6a2b2f8", 10070627937, 12842385408 }; #else static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 }; static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 }; diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 1dc0f6a7..cd9cc42c 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -220,6 +220,23 @@ void blockchain_storage::set_db_l2_cache_size(uint64_t ceched_elements) const m_db_assets.set_cache_size(ceched_elements); m_db_addr_to_alias.set_cache_size(ceched_elements); } + +void remove_old_db(const std::string old_db_folder_path) +{ + try { + if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path))) + { + LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0); + boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path)); + } + } + catch (...) + { + + } +} + + bool blockchain_storage::init(const std::string& config_folder, const boost::program_options::variables_map& vm) { // CRITICAL_REGION_LOCAL(m_read_lock); @@ -251,12 +268,10 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro m_config_folder = config_folder; // remove old incompatible DB - const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD; - if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path))) - { - LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0); - boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path)); - } + std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD; + remove_old_db(old_db_folder_path); + remove_old_db(dbbs.get_db_folder_path_old_1()); + remove_old_db(dbbs.get_db_folder_path_old_2()); const std::string db_folder_path = dbbs.get_db_folder_path(); LOG_PRINT_L0("Loading blockchain from " << db_folder_path); @@ -4248,7 +4263,6 @@ bool blockchain_storage::pop_asset_info(const asset_descriptor_operation& ado, c if (is_hardfork_active_for_height(ZANO_HARDFORK_05, height)) { // NEW HF5 handling - assets_container::t_value_type local_asset_hist = *asset_history_ptr; asset_descriptor_operation& last_ado = local_asset_hist.back(); // above we made sure that the history isn't empty CHECK_AND_ASSERT_MES(last_ado.opt_descriptor.has_value(), false, "opt_descriptor is missing during asset pop, op: " << (int)ado.operation_type); asset_descriptor_base& last_adb = last_ado.opt_descriptor.get(); diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 007c6ca6..b0407fd9 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -724,7 +724,7 @@ namespace currency bool is_output_allowed_for_input(const txout_to_key& out_v, const txin_v& in_v) const; bool is_output_allowed_for_input(const txout_htlc& out_v, const txin_v& in_v, uint64_t top_minus_source_height) const; bool is_output_allowed_for_input(const tx_out_zarcanum& out, const txin_v& in_v) const; - + void remove_old_dbs(); //POS diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index c3f344ea..f621d83b 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -232,7 +232,11 @@ #define CURRENCY_POOLDATA_FOLDERNAME_PREFIX "poolstate_" #define CURRENCY_POOLDATA_FOLDERNAME_SUFFIX "_v1" #define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX "blockchain_" -#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v2" +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v3" + +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1 "_v1" +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2 "_v2" + #define P2P_NET_DATA_FILENAME "p2pstate.bin" #define MINER_CONFIG_FILENAME "miner_conf.json" diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 86abbfd1..6c3fab82 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -561,6 +561,7 @@ namespace currency LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_GET_OBJECTS: block with id=" << epst::pod_to_hex(get_blob_hash(block_entry.block)) << " wasn't requested, dropping connection"); m_p2p->drop_connection(context); + m_p2p->add_ip_fail(context.m_remote_ip); return 1; } if(b.tx_hashes.size() != block_entry.txs.size()) diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index a238f63f..6cb58abb 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -34,7 +34,8 @@ using namespace epee; #define LOG_DEFAULT_CHANNEL "p2p" ENABLE_CHANNEL_BY_DEFAULT(LOG_DEFAULT_CHANNEL); -#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+13) + +#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+14) #define P2P_SERVER_DEFAULT_THREADS_NUM 10 diff --git a/src/version.h.in b/src/version.h.in index 5c997eae..90aeb815 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "2" #define PROJECT_MINOR_VERSION "1" -#define PROJECT_REVISION "2" +#define PROJECT_REVISION "5" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 394 +#define PROJECT_VERSION_BUILD_NO 397 #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 "]"