From 53c1a456651ce2571cc6fcb842f7ab8ce6714931 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 9 May 2019 12:37:17 +0200 Subject: [PATCH 1/4] disabled cache for db --- src/common/db_abstract_accessor.h | 4 ++-- src/currency_core/currency_config.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/db_abstract_accessor.h b/src/common/db_abstract_accessor.h index 61126293..4568c3bc 100644 --- a/src/common/db_abstract_accessor.h +++ b/src/common/db_abstract_accessor.h @@ -695,8 +695,8 @@ namespace tools typedef basic_key_value_accessor base_class; - typedef epee::misc_utils::cache_with_write_isolation, 10000> cache_container_type; - //typedef epee::misc_utils::cache_dummy, 100000> cache_container_type; + //typedef epee::misc_utils::cache_with_write_isolation, 10000> cache_container_type; + typedef epee::misc_utils::cache_dummy, 100000> cache_container_type; mutable cache_container_type m_cache; diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index c406309c..35b9cdca 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -205,7 +205,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 + 5 +#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 6 #define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1 From 7c5b7b8bcbeeaabbf05d96b959d1ea239e344203 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 9 May 2019 13:43:04 +0200 Subject: [PATCH 2/4] fixed bug with cache sync --- src/currency_core/blockchain_storage.cpp | 5 +++++ src/currency_core/blockchain_storage.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 7c99693a..3db594ca 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -902,6 +902,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con return DIFFICULTY_STARTER; //skip genesis timestamp TIME_MEASURE_START_PD(target_calculating_enum_blocks); + CRITICAL_REGION_BEGIN(m_targetdata_cache_lock); std::list>& targetdata_cache = pos ? m_pos_targetdata_cache : m_pow_targetdata_cache; //if (targetdata_cache.empty()) load_targetdata_cache(pos); @@ -913,6 +914,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con commulative_difficulties.push_back(it->first); ++count; } + CRITICAL_REGION_END(); wide_difficulty_type& dif = pos ? m_cached_next_pos_difficulty : m_cached_next_pow_difficulty; TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks); @@ -4594,6 +4596,7 @@ void blockchain_storage::on_block_removed(const block_extended_info& bei) //------------------------------------------------------------------ void blockchain_storage::update_targetdata_cache_on_block_added(const block_extended_info& bei) { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); if (bei.height == 0) return; //skip genesis std::list>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache; @@ -4604,6 +4607,7 @@ void blockchain_storage::update_targetdata_cache_on_block_added(const block_exte //------------------------------------------------------------------ void blockchain_storage::update_targetdata_cache_on_block_removed(const block_extended_info& bei) { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); std::list>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache; if (targetdata_cache.size()) targetdata_cache.pop_back(); @@ -4613,6 +4617,7 @@ void blockchain_storage::update_targetdata_cache_on_block_removed(const block_ex //------------------------------------------------------------------ void blockchain_storage::load_targetdata_cache(bool is_pos)const { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); std::list>& targetdata_cache = is_pos? m_pos_targetdata_cache: m_pow_targetdata_cache; targetdata_cache.clear(); uint64_t stop_ind = 0; diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index eaa12740..580afe81 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -511,6 +511,7 @@ namespace currency mutable wide_difficulty_type m_cached_next_pow_difficulty; mutable wide_difficulty_type m_cached_next_pos_difficulty; + mutable critical_section m_targetdata_cache_lock; mutable std::list > m_pos_targetdata_cache; mutable std::list > m_pow_targetdata_cache; //work like a cache to avoid recalculation on read operations From cdbe023198bbbc28b6fdfbb6425db0dcc01a133b Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 9 May 2019 13:44:14 +0200 Subject: [PATCH 3/4] dropped blockchain in case it broken --- src/currency_core/currency_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 35b9cdca..2e4e9303 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -205,7 +205,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 + 6 +#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 7 #define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1 From c1d15aeabed6665ecc0a3495b7d6b1eec71e440b Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 9 May 2019 14:27:28 +0200 Subject: [PATCH 4/4] enabled db cache --- src/common/db_abstract_accessor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/db_abstract_accessor.h b/src/common/db_abstract_accessor.h index 4568c3bc..61126293 100644 --- a/src/common/db_abstract_accessor.h +++ b/src/common/db_abstract_accessor.h @@ -695,8 +695,8 @@ namespace tools typedef basic_key_value_accessor base_class; - //typedef epee::misc_utils::cache_with_write_isolation, 10000> cache_container_type; - typedef epee::misc_utils::cache_dummy, 100000> cache_container_type; + typedef epee::misc_utils::cache_with_write_isolation, 10000> cache_container_type; + //typedef epee::misc_utils::cache_dummy, 100000> cache_container_type; mutable cache_container_type m_cache;