diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-23 13:05:48 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-05 11:58:18 +0000 |
commit | 88c85c18e0173f479470842fbe49626cdc86e7d1 (patch) | |
tree | b64a4166d561f19b7055df9c66602c2ba67e44a2 /src/cryptonote_core/blockchain.cpp | |
parent | cryptonote: speed up calculating coinbase tx prunable hash (diff) | |
download | monero-88c85c18e0173f479470842fbe49626cdc86e7d1.tar.xz |
cryptonote: avoid double parsing blocks when syncing
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 2890af628..2c1b9d447 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3889,11 +3889,9 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti return true; } //------------------------------------------------------------------ -bool Blockchain::add_new_block(const block& bl_, block_verification_context& bvc) +bool Blockchain::add_new_block(const block& bl, block_verification_context& bvc) { LOG_PRINT_L3("Blockchain::" << __func__); - //copy block here to let modify block.target - block bl = bl_; crypto::hash id = get_block_hash(bl); CRITICAL_REGION_LOCAL(m_tx_pool);//to avoid deadlock lets lock tx_pool for whole add/reorganize process CRITICAL_REGION_LOCAL1(m_blockchain_lock); @@ -4296,14 +4294,12 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete if (block.prev_id != tophash) { MDEBUG("Skipping prepare blocks. New blocks don't belong to chain."); + blocks.clear(); return true; } } if (have_block(get_block_hash(block))) - { blocks_exist = true; - break; - } std::advance(it, 1); } @@ -4317,10 +4313,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete return false; if (have_block(get_block_hash(block))) - { blocks_exist = true; - break; - } std::advance(it, 1); } @@ -4356,7 +4349,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete if (blocks_exist) { - MDEBUG("Skipping prepare blocks. Blocks exist."); + MDEBUG("Skipping remainder of prepare blocks. Blocks exist."); return true; } |