aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.h
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-07-19 03:36:39 -0700
committerAlexander Blair <snipa@jagtech.io>2020-07-19 03:36:39 -0700
commit36d50d93f295d4b193e73f3ff3e95ae7e050c767 (patch)
treec8c7b69c5b0f769fdf1f72460462851597506d88 /src/cryptonote_core/blockchain.h
parentMerge pull request #6529 (diff)
parentdaemon: guard against rare 'difficulty drift' bug with checkpoints and recalc... (diff)
downloadmonero-36d50d93f295d4b193e73f3ff3e95ae7e050c767.tar.xz
Merge pull request #6534
7bd66b01b daemon: guard against rare 'difficulty drift' bug with checkpoints and recalculation (stoffu)
Diffstat (limited to 'src/cryptonote_core/blockchain.h')
-rw-r--r--src/cryptonote_core/blockchain.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 966e98f7e..fb7e5c4f8 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -310,6 +310,22 @@ namespace cryptonote
difficulty_type get_difficulty_for_next_block();
/**
+ * @brief check currently stored difficulties against difficulty checkpoints
+ *
+ * @return {flag, height} flag: true if all difficulty checkpoints pass, height: the last checkpoint height before the difficulty drift bug starts
+ */
+ std::pair<bool, uint64_t> check_difficulty_checkpoints() const;
+
+ /**
+ * @brief recalculate difficulties for blocks after the last difficulty checkpoints to circumvent the annoying 'difficulty drift' bug
+ *
+ * @param start_height: if omitted, starts recalculation from the last difficulty checkpoint
+ *
+ * @return number of blocks whose difficulties got corrected
+ */
+ size_t recalculate_difficulties(boost::optional<uint64_t> start_height = boost::none);
+
+ /**
* @brief adds a block to the blockchain
*
* Adds a new block to the blockchain. If the block's parent is not the