From d3f9a44e5790d399571f33b6d03517df7af6551b Mon Sep 17 00:00:00 2001 From: Anthony Fieroni Date: Tue, 25 Feb 2020 09:19:14 +0200 Subject: [PATCH] Adjust best fork warning conditions Signed-off-by: Anthony Fieroni --- src/validation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 28e4c476b..f10c00167 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1443,9 +1443,9 @@ static void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main) if (::ChainstateActive().IsInitialBlockDownload()) return; - // If our best fork is no longer within 72 blocks (+/- 12 hours if no one mines it) + // If our best fork is no longer within 288 blocks (~ 24 blocks per hour +/- 12 hours if no one mines it) // of our head, drop it - if (pindexBestForkTip && ::ChainActive().Height() - pindexBestForkTip->nHeight >= 72) + if (pindexBestForkTip && ::ChainActive().Height() - pindexBestForkTip->nHeight >= 288) pindexBestForkTip = nullptr; if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > ::ChainActive().Tip()->nChainWork + (GetBlockProof(*::ChainActive().Tip()) * 6))) @@ -1492,7 +1492,7 @@ static void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) E } // We define a condition where we should warn the user about as a fork of at least 7 blocks - // with a tip within 72 blocks (+/- 12 hours if no one mines it) of ours + // with a tip within 288 blocks (+/- 12 hours if no one mines it) of ours // We use 7 blocks rather arbitrarily as it represents just under 10% of sustained network // hash rate operating on the fork. // or a chain that is entirely longer than ours and invalid (note that this should be detected by both) @@ -1500,7 +1500,7 @@ static void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) E // the 7-block condition and from this always have the most-likely-to-cause-warning fork if (pfork && (!pindexBestForkTip || pindexNewForkTip->nHeight > pindexBestForkTip->nHeight) && pindexNewForkTip->nChainWork - pfork->nChainWork > (GetBlockProof(*pfork) * 7) && - ::ChainActive().Height() - pindexNewForkTip->nHeight < 72) + ::ChainActive().Height() - pindexNewForkTip->nHeight < 288) { pindexBestForkTip = pindexNewForkTip; pindexBestForkBase = pfork;