Merge pull request #5337 from LarryRuane/2021-09-testIBD
Fix two boost tests that require post-IBD
This commit is contained in:
commit
1a7c2a3b04
15
src/main.cpp
15
src/main.cpp
|
@ -2239,16 +2239,23 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
|||
}
|
||||
}
|
||||
|
||||
static std::atomic<bool> IBDLatchToFalse{false};
|
||||
// testing-only, allow initial block down state to be set or reset
|
||||
bool TestSetIBD(bool ibd) {
|
||||
bool ret = !IBDLatchToFalse;
|
||||
IBDLatchToFalse.store(!ibd, std::memory_order_relaxed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool IsInitialBlockDownload(const Consensus::Params& params)
|
||||
{
|
||||
// Once this function has returned false, it must remain false.
|
||||
static std::atomic<bool> latchToFalse{false};
|
||||
// Optimization: pre-test latch before taking the lock.
|
||||
if (latchToFalse.load(std::memory_order_relaxed))
|
||||
if (IBDLatchToFalse.load(std::memory_order_relaxed))
|
||||
return false;
|
||||
|
||||
LOCK(cs_main);
|
||||
if (latchToFalse.load(std::memory_order_relaxed))
|
||||
if (IBDLatchToFalse.load(std::memory_order_relaxed))
|
||||
return false;
|
||||
if (fImporting || fReindex)
|
||||
return true;
|
||||
|
@ -2310,7 +2317,7 @@ bool IsInitialBlockDownload(const Consensus::Params& params)
|
|||
if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge))
|
||||
return true;
|
||||
LogPrintf("Leaving InitialBlockDownload (latching to false)\n");
|
||||
latchToFalse.store(true, std::memory_order_relaxed);
|
||||
IBDLatchToFalse.store(true, std::memory_order_relaxed);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,6 +273,8 @@ bool SendMessages(const Consensus::Params& params, CNode* pto);
|
|||
void ThreadScriptCheck();
|
||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||
bool IsInitialBlockDownload(const Consensus::Params& params);
|
||||
/** testing-only, set or reset initial block down (IBD) state, return previous */
|
||||
bool TestSetIBD(bool);
|
||||
/** Format a string that describes several potential problems detected by the core */
|
||||
std::pair<std::string, int64_t> GetWarnings(const std::string& strFor);
|
||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||
|
|
|
@ -78,6 +78,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
|
|||
fCheckBlockIndex = true;
|
||||
SelectParams(chainName);
|
||||
noui_connect();
|
||||
TestSetIBD(false);
|
||||
}
|
||||
|
||||
BasicTestingSetup::~BasicTestingSetup()
|
||||
|
|
Loading…
Reference in New Issue