Add what seems to be missing locks in mining code

This commit is contained in:
Duke
2024-09-11 23:59:57 -04:00
parent b71d95bdd4
commit b4e083ae56

View File

@@ -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) {