aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 761680016..1367eabd8 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -456,6 +456,14 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
if (!update_next_cumulative_weight_limit())
return false;
}
+
+ if (m_hardfork->get_current_version() >= RX_BLOCK_VERSION)
+ {
+ const crypto::hash seedhash = get_block_id_by_height(crypto::rx_seedheight(m_db->height()));
+ if (seedhash != crypto::null_hash)
+ rx_set_main_seedhash(seedhash.data, tools::get_max_concurrency());
+ }
+
return true;
}
//------------------------------------------------------------------
@@ -570,6 +578,12 @@ void Blockchain::pop_blocks(uint64_t nblocks)
if (stop_batch)
m_db->batch_stop();
+
+ if (m_hardfork->get_current_version() >= RX_BLOCK_VERSION)
+ {
+ const crypto::hash seedhash = get_block_id_by_height(crypto::rx_seedheight(m_db->height()));
+ rx_set_main_seedhash(seedhash.data, tools::get_max_concurrency());
+ }
}
//------------------------------------------------------------------
// This function tells BlockchainDB to remove the top block from the
@@ -1239,18 +1253,20 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
}
m_hardfork->reorganize_from_chain_height(split_height);
- get_block_longhash_reorg(split_height);
std::shared_ptr<tools::Notify> reorg_notify = m_reorg_notify;
if (reorg_notify)
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);
+ const uint64_t new_height = m_db->height();
+ const crypto::hash seedhash = get_block_id_by_height(crypto::rx_seedheight(new_height));
+
crypto::hash prev_id;
if (!get_block_hash(alt_chain.back().bl, prev_id))
MERROR("Failed to get block hash of an alternative chain's tip");
else
- send_miner_notifications(prev_id, alt_chain.back().already_generated_coins);
+ send_miner_notifications(new_height, seedhash, prev_id, alt_chain.back().already_generated_coins);
for (const auto& notifier : m_block_notifiers)
{
@@ -1262,6 +1278,9 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
}
}
+ if (m_hardfork->get_current_version() >= RX_BLOCK_VERSION)
+ rx_set_main_seedhash(seedhash.data, tools::get_max_concurrency());
+
MGINFO_GREEN("REORGANIZE SUCCESS! on height: " << split_height << ", new blockchain size: " << m_db->height());
return true;
}
@@ -2001,7 +2020,7 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
{
seedhash = get_block_id_by_height(seedheight);
}
- get_altblock_longhash(bei.bl, proof_of_work, get_current_blockchain_height(), bei.height, seedheight, seedhash);
+ get_altblock_longhash(bei.bl, proof_of_work, seedhash);
} else
{
get_block_longhash(this, bei.bl, proof_of_work, bei.height, 0);
@@ -4552,11 +4571,15 @@ leave:
}
}
- send_miner_notifications(id, already_generated_coins);
+ const crypto::hash seedhash = get_block_id_by_height(crypto::rx_seedheight(new_height));
+ send_miner_notifications(new_height, seedhash, id, already_generated_coins);
for (const auto& notifier: m_block_notifiers)
notifier(new_height - 1, {std::addressof(bl), 1});
+ if (m_hardfork->get_current_version() >= RX_BLOCK_VERSION)
+ rx_set_main_seedhash(seedhash.data, tools::get_max_concurrency());
+
return true;
}
//------------------------------------------------------------------
@@ -5761,24 +5784,15 @@ void Blockchain::cache_block_template(const block &b, const cryptonote::account_
m_btc_valid = true;
}
-void Blockchain::send_miner_notifications(const crypto::hash &prev_id, uint64_t already_generated_coins)
+void Blockchain::send_miner_notifications(uint64_t height, const crypto::hash &seed_hash, const crypto::hash &prev_id, uint64_t already_generated_coins)
{
if (m_miner_notifiers.empty())
return;
- const uint64_t height = m_db->height();
const uint8_t major_version = m_hardfork->get_ideal_version(height);
const difficulty_type diff = get_difficulty_for_next_block();
const uint64_t median_weight = m_current_block_cumul_weight_median;
- crypto::hash seed_hash = crypto::null_hash;
- if (m_hardfork->get_current_version() >= RX_BLOCK_VERSION)
- {
- uint64_t seed_height, next_height;
- crypto::rx_seedheights(height, &seed_height, &next_height);
- seed_hash = get_block_id_by_height(seed_height);
- }
-
std::vector<tx_block_template_backlog_entry> tx_backlog;
m_tx_pool.get_block_template_backlog(tx_backlog);