From 3f7d6fb57d1bfb5ee806d3facc1261efe3ad14a0 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 4 Dec 2016 12:27:45 +0000 Subject: Fix delayed exit when syncing --- src/cryptonote_core/blockchain.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/cryptonote_core/blockchain.cpp') diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index c2ccf3db0..9b9bbb4d4 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -118,7 +118,7 @@ static const uint64_t testnet_hard_fork_version_1_till = 624633; //------------------------------------------------------------------ Blockchain::Blockchain(tx_memory_pool& tx_pool) : m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_sz_limit(0), m_is_in_checkpoint_zone(false), - m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0) + m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0), m_cancel(false) { LOG_PRINT_L3("Blockchain::" << __func__); } @@ -3436,6 +3436,8 @@ void Blockchain::block_longhash_worker(const uint64_t height, const std::vector< // the height of the block passed to it for (const auto & block : blocks) { + if (m_cancel) + return; crypto::hash id = get_block_hash(block); crypto::hash pow = get_block_longhash(block, height); map.emplace(id, pow); @@ -3611,6 +3613,9 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list> Blockchain:: get_ou return m_db->get_output_histogram(amounts, unlocked, recent_cutoff); } +void Blockchain::cancel() +{ + m_cancel = true; +} + #if defined(PER_BLOCK_CHECKPOINT) void Blockchain::load_compiled_in_block_hashes() { -- cgit v1.2.3