Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,023 Lines • ▼ Show 20 Lines | CheckForkWarningConditionsOnNewFork(const CBlockIndex *pindexNewForkTip) { | ||||
// least 7 blocks with a tip within 72 blocks (+/- 12 hours if no one mines | // least 7 blocks with a tip within 72 blocks (+/- 12 hours if no one mines | ||||
// it) of ours. We use 7 blocks rather arbitrarily as it represents just | // 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 | // 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 | // chain that is entirely longer than ours and invalid (note that this | ||||
// should be detected by both). We define it this way because it allows us | // should be detected by both). We define it this way because it allows us | ||||
// to only store the highest fork tip (+ base) which meets the 7-block | // to only store the highest fork tip (+ base) which meets the 7-block | ||||
// condition and from this always have the most-likely-to-cause-warning fork | // condition and from this always have the most-likely-to-cause-warning fork | ||||
if (pfork && (!pindexBestForkTip || | if (pfork && (!pindexBestForkTip || | ||||
(pindexBestForkTip && | pindexNewForkTip->nHeight > pindexBestForkTip->nHeight) && | ||||
pindexNewForkTip->nHeight > pindexBestForkTip->nHeight)) && | |||||
pindexNewForkTip->nChainWork - pfork->nChainWork > | pindexNewForkTip->nChainWork - pfork->nChainWork > | ||||
(GetBlockProof(*pfork) * 7) && | (GetBlockProof(*pfork) * 7) && | ||||
chainActive.Height() - pindexNewForkTip->nHeight < 72) { | chainActive.Height() - pindexNewForkTip->nHeight < 72) { | ||||
pindexBestForkTip = pindexNewForkTip; | pindexBestForkTip = pindexNewForkTip; | ||||
pindexBestForkBase = pfork; | pindexBestForkBase = pfork; | ||||
} | } | ||||
CheckForkWarningConditions(); | CheckForkWarningConditions(); | ||||
▲ Show 20 Lines • Show All 4,440 Lines • Show Last 20 Lines |