From d25b0b6ebdc05f4b05f531478bc52f9219aee333 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 5 Dec 2020 23:51:09 +0000 Subject: [PATCH] blockchain: only update pruning when the chain changed Most of the addition calls will end up adding nothing, since we expect to receive every block from all peers, and only the first time we get it leads to actual addition. --- src/cryptonote_core/blockchain.cpp | 12 +++++++++--- src/cryptonote_core/blockchain.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index ad27f1358..284fc8f34 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -88,7 +88,7 @@ DISABLE_VS_WARNINGS(4267) //------------------------------------------------------------------ Blockchain::Blockchain(tx_memory_pool& tx_pool) : m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_reset_timestamps_and_difficulties_height(true), m_current_block_cumul_weight_limit(0), m_current_block_cumul_weight_median(0), - m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_sync_on_blocks(true), m_db_sync_threshold(1), m_db_sync_mode(db_async), m_db_default_sync(false), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0), m_bytes_to_sync(0), m_cancel(false), + m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_sync_on_blocks(true), m_db_sync_threshold(1), m_db_sync_mode(db_async), m_db_default_sync(false), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0), m_update_pruning(false), m_bytes_to_sync(0), m_cancel(false), m_long_term_block_weights_window(CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE), m_long_term_effective_median_block_weight(0), m_long_term_block_weights_cache_tip_hash(crypto::null_hash), @@ -647,6 +647,7 @@ block Blockchain::pop_block_from_blockchain() crypto::hash top_block_hash = get_tail_id(top_block_height); m_tx_pool.on_blockchain_dec(top_block_height, top_block_hash); invalidate_block_template_cache(); + m_update_pruning = true; return popped_block; } @@ -4339,6 +4340,7 @@ leave: bvc.m_added_to_main_chain = true; ++m_sync_counter; + m_update_pruning = true; // appears to be a NOP *and* is called elsewhere. wat? m_tx_pool.on_blockchain_inc(new_height, id); @@ -4617,7 +4619,7 @@ void Blockchain::block_longhash_worker(uint64_t height, const epee::span