mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Fix csBestBlock/cvBlockChange waiting in rpc/mining
This commit is contained in:
parent
ad960f5771
commit
45dd135039
@ -471,7 +471,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
|
||||
|
||||
WaitableLock lock(csBestBlock);
|
||||
while (chainActive.Tip()->GetBlockHash() == hashWatchedChain && IsRPCRunning())
|
||||
while (hashBestBlock == hashWatchedChain && IsRPCRunning())
|
||||
{
|
||||
if (cvBlockChange.wait_until(lock, checktxtime) == std::cv_status::timeout)
|
||||
{
|
||||
|
@ -204,6 +204,7 @@ CChain& chainActive = g_chainstate.chainActive;
|
||||
CBlockIndex *pindexBestHeader = nullptr;
|
||||
CWaitableCriticalSection csBestBlock;
|
||||
CConditionVariable cvBlockChange;
|
||||
uint256 hashBestBlock;
|
||||
int nScriptCheckThreads = 0;
|
||||
std::atomic_bool fImporting(false);
|
||||
std::atomic_bool fReindex(false);
|
||||
@ -2195,7 +2196,11 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
// New best block
|
||||
mempool.AddTransactionsUpdated(1);
|
||||
|
||||
cvBlockChange.notify_all();
|
||||
{
|
||||
WaitableLock lock(csBestBlock);
|
||||
hashBestBlock = pindexNew->GetBlockHash();
|
||||
cvBlockChange.notify_all();
|
||||
}
|
||||
|
||||
std::vector<std::string> warningMessages;
|
||||
if (!IsInitialBlockDownload())
|
||||
|
@ -166,6 +166,7 @@ extern uint64_t nLastBlockWeight;
|
||||
extern const std::string strMessageMagic;
|
||||
extern CWaitableCriticalSection csBestBlock;
|
||||
extern CConditionVariable cvBlockChange;
|
||||
extern uint256 hashBestBlock;
|
||||
extern std::atomic_bool fImporting;
|
||||
extern std::atomic_bool fReindex;
|
||||
extern int nScriptCheckThreads;
|
||||
|
Loading…
Reference in New Issue
Block a user