aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2020-05-15 10:56:23 +0900
committerstoffu <stoffu@protonmail.ch>2020-06-09 10:40:51 +0900
commit7bd66b01bfb62ecaf8ff02b20d14db3a77322abc (patch)
treec6a4db2a82193471570360734f4c4955271a69ba /src/cryptonote_core/cryptonote_core.cpp
parentMerge pull request #6576 (diff)
downloadmonero-7bd66b01bfb62ecaf8ff02b20d14db3a77322abc.tar.xz
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.
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 0f8bde3e9..5e4a1accd 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1662,6 +1662,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;
@@ -1923,6 +1924,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();