Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,338 Lines • ▼ Show 20 Lines | void Chainstate::CheckForkWarningConditions() { | ||||
// Before we get past initial download, we cannot reliably alert about forks | // Before we get past initial download, we cannot reliably alert about forks | ||||
// (we assume we don't get stuck on a fork before finishing our initial | // (we assume we don't get stuck on a fork before finishing our initial | ||||
// sync) | // sync) | ||||
if (IsInitialBlockDownload()) { | if (IsInitialBlockDownload()) { | ||||
return; | return; | ||||
} | } | ||||
// If our best fork is no longer within 72 blocks (+/- 12 hours if no one | // If our best fork is no longer within 72 blocks (+/- 12 hours if no one | ||||
// mines it) of our head, drop it | // mines it) of our head, or if it is back on the active chain, drop it | ||||
if (m_best_fork_tip && m_chain.Height() - m_best_fork_tip->nHeight >= 72) { | if (m_best_fork_tip && (m_chain.Height() - m_best_fork_tip->nHeight >= 72 || | ||||
m_chain.Contains(m_best_fork_tip))) { | |||||
m_best_fork_tip = nullptr; | m_best_fork_tip = nullptr; | ||||
} | } | ||||
if (m_best_fork_tip || | if (m_best_fork_tip || | ||||
(m_chainman.m_best_invalid && | (m_chainman.m_best_invalid && | ||||
m_chainman.m_best_invalid->nChainWork > | m_chainman.m_best_invalid->nChainWork > | ||||
m_chain.Tip()->nChainWork + (GetBlockProof(*m_chain.Tip()) * 6))) { | m_chain.Tip()->nChainWork + (GetBlockProof(*m_chain.Tip()) * 6))) { | ||||
if (!GetfLargeWorkForkFound() && m_best_fork_base) { | if (!GetfLargeWorkForkFound() && m_best_fork_base) { | ||||
▲ Show 20 Lines • Show All 4,883 Lines • Show Last 20 Lines |