diff --git a/src/miner.cpp b/src/miner.cpp index 356374207..436a59262 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -893,6 +893,7 @@ static bool ProcessBlockFound(CBlock* pblock) // Found a solution { + LOCK(cs_main); if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash()) { uint256 hash; int32_t i; @@ -1136,7 +1137,11 @@ void static RandomXMiner() // Create new block unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); - CBlockIndex* pindexPrev = chainActive.LastTip(); + CBlockIndex* pindexPrev; + { + LOCK(cs_main); + pindexPrev = chainActive.LastTip(); + } // If we don't have a valid chain tip to work from, wait and try again. if (pindexPrev == nullptr) {