diff options
author | stoffu <stoffu@protonmail.ch> | 2020-05-15 10:56:23 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2020-06-09 10:40:51 +0900 |
commit | 7bd66b01bfb62ecaf8ff02b20d14db3a77322abc (patch) | |
tree | c6a4db2a82193471570360734f4c4955271a69ba /src/blockchain_db/blockchain_db.h | |
parent | Merge pull request #6576 (diff) | |
download | monero-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 '')
-rw-r--r-- | src/blockchain_db/blockchain_db.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 3e2387da4..8cf84ef4f 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -1039,6 +1039,16 @@ public: virtual difficulty_type get_block_difficulty(const uint64_t& height) const = 0; /** + * @brief correct blocks cumulative difficulties that were incorrectly calculated due to the 'difficulty drift' bug + * + * If the block does not exist, the subclass should throw BLOCK_DNE + * + * @param start_height the height where the drift starts + * @param new_cumulative_difficulties new cumulative difficulties to be stored + */ + virtual void correct_block_cumulative_difficulties(const uint64_t& start_height, const std::vector<difficulty_type>& new_cumulative_difficulties) = 0; + + /** * @brief fetch a block's already generated coins * * The subclass should return the total coins generated as of the block |