| 1207 | } |
| 1208 | |
| 1209 | bool IsInitialBlockDownload() |
| 1210 | { |
| 1211 | // Once this function has returned false, it must remain false. |
| 1212 | static std::atomic<bool> latchToFalse{false}; |
| 1213 | // Optimization: pre-test latch before taking the lock. |
| 1214 | if (latchToFalse.load(std::memory_order_relaxed)) |
| 1215 | return false; |
| 1216 | |
| 1217 | LOCK(cs_main); |
| 1218 | if (latchToFalse.load(std::memory_order_relaxed)) |
| 1219 | return false; |
| 1220 | if (fImporting || fReindex) |
| 1221 | return true; |
| 1222 | if (chainActive.Tip() == nullptr) |
| 1223 | return true; |
| 1224 | if (chainActive.Tip()->nChainWork < nMinimumChainWork) |
| 1225 | return true; |
| 1226 | if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge)) |
| 1227 | return true; |
| 1228 | LogPrintf("Leaving InitialBlockDownload (latching to false)\n"); |
| 1229 | latchToFalse.store(true, std::memory_order_relaxed); |
| 1230 | return false; |
| 1231 | } |
| 1232 | |
| 1233 | CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr; |
| 1234 |
no test coverage detected