mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 00:08:54 +00:00
Merge pull request #6347
fcb06f7
cryptonote_core: skip block notify on blockchain switching rollback (xiphon)
This commit is contained in:
commit
44547006bf
@ -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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1212,10 +1212,11 @@ namespace cryptonote
|
||||
*
|
||||
* @param bl the block to be added
|
||||
* @param bvc metadata concerning the block's validity
|
||||
* @param notify if set to true, sends new block notification on success
|
||||
*
|
||||
* @return true if the block was added successfully, otherwise false
|
||||
*/
|
||||
bool handle_block_to_main_chain(const block& bl, block_verification_context& bvc);
|
||||
bool handle_block_to_main_chain(const block& bl, block_verification_context& bvc, bool notify = true);
|
||||
|
||||
/**
|
||||
* @brief validate and add a new block to the end of the blockchain
|
||||
@ -1227,10 +1228,11 @@ namespace cryptonote
|
||||
* @param bl the block to be added
|
||||
* @param id the hash of the block
|
||||
* @param bvc metadata concerning the block's validity
|
||||
* @param notify if set to true, sends new block notification on success
|
||||
*
|
||||
* @return true if the block was added successfully, otherwise false
|
||||
*/
|
||||
bool handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc);
|
||||
bool handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc, bool notify = true);
|
||||
|
||||
/**
|
||||
* @brief validate and add a new block to an alternate blockchain
|
||||
|
Loading…
Reference in New Issue
Block a user