daemon: guard against rare 'difficulty drift' bug with checkpoints and recalculation

On startup, it checks against the difficulty checkpoints, and if any mismatch is found, recalculates all the blocks with wrong difficulties. Additionally, once a week it recalculates difficulties of blocks after the last difficulty checkpoint.
This commit is contained in:
stoffu
2020-07-20 00:41:18 +03:00
committed by wowario
parent 6a829c77e1
commit 5b83ccbb2d
10 changed files with 242 additions and 63 deletions
+7
View File
@@ -1726,6 +1726,7 @@ namespace cryptonote
m_check_disk_space_interval.do_call(boost::bind(&core::check_disk_space, this));
m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
m_blockchain_pruning_interval.do_call(boost::bind(&core::update_blockchain_pruning, this));
m_diff_recalc_interval.do_call(boost::bind(&core::recalculate_difficulties, this));
m_miner.on_idle();
m_mempool.on_idle();
return true;
@@ -1964,6 +1965,12 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
bool core::recalculate_difficulties()
{
m_blockchain_storage.recalculate_difficulties();
return true;
}
//-----------------------------------------------------------------------------------------------
void core::flush_bad_txs_cache()
{
bad_semantics_txes_lock.lock();