Enhance mainchain reorg handling with mining pause and robust recovery
This commit is contained in:
@@ -114,6 +114,11 @@ public:
|
||||
void check_and_run_deferred_recovery();
|
||||
bool is_in_recovery() const { return m_recoveryMode.load(); }
|
||||
|
||||
// Mainchain reorg handling
|
||||
void on_mainchain_reorg(uint64_t split_height, const hash& old_block_hash);
|
||||
bool is_in_reorg_grace_period() const;
|
||||
static constexpr uint64_t REORG_GRACE_PERIOD_SECONDS = 60;
|
||||
|
||||
[[nodiscard]] FORCEINLINE difficulty_type difficulty() const { ReadLock lock(m_curDifficultyLock); return m_curDifficulty; }
|
||||
[[nodiscard]] difficulty_type total_hashes() const;
|
||||
[[nodiscard]] uint64_t block_time() const { return m_targetBlockTime; }
|
||||
@@ -245,6 +250,10 @@ private:
|
||||
std::atomic<uint64_t> m_pendingRecoveryHeight{0};
|
||||
bool m_checkpointsNeedValidation{false};
|
||||
|
||||
// Mainchain reorg tracking
|
||||
std::atomic<uint64_t> m_reorgGracePeriodEnd{0};
|
||||
std::atomic<uint64_t> m_lastReorgHeight{0};
|
||||
|
||||
hash m_consensusHash;
|
||||
|
||||
void launch_precalc(const PoolBlock* block);
|
||||
|
||||
Reference in New Issue
Block a user