diff options
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index f0d5828ec..7a13705a3 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -928,7 +928,7 @@ bool Blockchain::rollback_blockchain_switching(std::list<block>& original_chain, for (auto& bl : original_chain) { block_verification_context bvc = {}; - bool r = handle_block_to_main_chain(bl, bvc); + bool r = handle_block_to_main_chain(bl, bvc, false); CHECK_AND_ASSERT_MES(r && bvc.m_added_to_main_chain, false, "PANIC! failed to add (again) block while chain switching during the rollback!"); } @@ -979,7 +979,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info> block_verification_context bvc = {}; // add block to main chain - bool r = handle_block_to_main_chain(bei.bl, bvc); + bool r = handle_block_to_main_chain(bei.bl, bvc, false); // if adding block to main chain failed, rollback to previous state and // return false @@ -1044,6 +1044,11 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info> reorg_notify->notify("%s", std::to_string(split_height).c_str(), "%h", std::to_string(m_db->height()).c_str(), "%n", std::to_string(m_db->height() - split_height).c_str(), "%d", std::to_string(discarded_blocks).c_str(), NULL); + std::shared_ptr<tools::Notify> block_notify = m_block_notify; + if (block_notify) + for (const auto &bei: alt_chain) + block_notify->notify("%s", epee::string_tools::pod_to_hex(get_block_hash(bei.bl)).c_str(), NULL); + MGINFO_GREEN("REORGANIZE SUCCESS! on height: " << split_height << ", new blockchain size: " << m_db->height()); return true; } @@ -2574,11 +2579,11 @@ bool Blockchain::have_block(const crypto::hash& id) const return false; } //------------------------------------------------------------------ -bool Blockchain::handle_block_to_main_chain(const block& bl, block_verification_context& bvc) +bool Blockchain::handle_block_to_main_chain(const block& bl, block_verification_context& bvc, bool notify/* = true*/) { LOG_PRINT_L3("Blockchain::" << __func__); crypto::hash id = get_block_hash(bl); - return handle_block_to_main_chain(bl, id, bvc); + return handle_block_to_main_chain(bl, id, bvc, notify); } //------------------------------------------------------------------ size_t Blockchain::get_total_transactions() const @@ -3687,7 +3692,7 @@ bool Blockchain::flush_txes_from_pool(const std::vector<crypto::hash> &txids) // Needs to validate the block and acquire each transaction from the // transaction mem_pool, then pass the block and transactions to // m_db->add_block() -bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc) +bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc, bool notify/* = true*/) { LOG_PRINT_L3("Blockchain::" << __func__); @@ -4067,9 +4072,12 @@ leave: get_difficulty_for_next_block(); // just to cache it invalidate_block_template_cache(); - std::shared_ptr<tools::Notify> block_notify = m_block_notify; - if (block_notify) - block_notify->notify("%s", epee::string_tools::pod_to_hex(id).c_str(), NULL); + if (notify) + { + std::shared_ptr<tools::Notify> block_notify = m_block_notify; + if (block_notify) + block_notify->notify("%s", epee::string_tools::pod_to_hex(id).c_str(), NULL); + } return true; } |