mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-12 13:41:52 +00:00
Fix csBestBlock/cvBlockChange waiting in rpc/mining
Github-Pull: #12743 Rebased-From: 45dd13503918e75a45ce33eb5c934b998790fdc8
This commit is contained in:
parent
88d1a649a2
commit
657dfc5bca
@ -477,7 +477,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||||||
checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
|
checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
|
||||||
|
|
||||||
WaitableLock lock(csBestBlock);
|
WaitableLock lock(csBestBlock);
|
||||||
while (chainActive.Tip()->GetBlockHash() == hashWatchedChain && IsRPCRunning())
|
while (hashBestBlock == hashWatchedChain && IsRPCRunning())
|
||||||
{
|
{
|
||||||
if (cvBlockChange.wait_until(lock, checktxtime) == std::cv_status::timeout)
|
if (cvBlockChange.wait_until(lock, checktxtime) == std::cv_status::timeout)
|
||||||
{
|
{
|
||||||
|
@ -210,6 +210,7 @@ CChain& chainActive = g_chainstate.chainActive;
|
|||||||
CBlockIndex *pindexBestHeader = nullptr;
|
CBlockIndex *pindexBestHeader = nullptr;
|
||||||
CWaitableCriticalSection csBestBlock;
|
CWaitableCriticalSection csBestBlock;
|
||||||
CConditionVariable cvBlockChange;
|
CConditionVariable cvBlockChange;
|
||||||
|
uint256 hashBestBlock;
|
||||||
int nScriptCheckThreads = 0;
|
int nScriptCheckThreads = 0;
|
||||||
std::atomic_bool fImporting(false);
|
std::atomic_bool fImporting(false);
|
||||||
std::atomic_bool fReindex(false);
|
std::atomic_bool fReindex(false);
|
||||||
@ -2151,7 +2152,11 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
|||||||
// New best block
|
// New best block
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
|
|
||||||
cvBlockChange.notify_all();
|
{
|
||||||
|
WaitableLock lock(csBestBlock);
|
||||||
|
hashBestBlock = pindexNew->GetBlockHash();
|
||||||
|
cvBlockChange.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> warningMessages;
|
std::vector<std::string> warningMessages;
|
||||||
if (!IsInitialBlockDownload())
|
if (!IsInitialBlockDownload())
|
||||||
|
@ -166,6 +166,7 @@ extern uint64_t nLastBlockWeight;
|
|||||||
extern const std::string strMessageMagic;
|
extern const std::string strMessageMagic;
|
||||||
extern CWaitableCriticalSection csBestBlock;
|
extern CWaitableCriticalSection csBestBlock;
|
||||||
extern CConditionVariable cvBlockChange;
|
extern CConditionVariable cvBlockChange;
|
||||||
|
extern uint256 hashBestBlock;
|
||||||
extern std::atomic_bool fImporting;
|
extern std::atomic_bool fImporting;
|
||||||
extern std::atomic_bool fReindex;
|
extern std::atomic_bool fReindex;
|
||||||
extern int nScriptCheckThreads;
|
extern int nScriptCheckThreads;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user