Add what seems to be missing locks in mining code
This commit is contained in:
@@ -893,6 +893,7 @@ static bool ProcessBlockFound(CBlock* pblock)
|
|||||||
|
|
||||||
// Found a solution
|
// Found a solution
|
||||||
{
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
||||||
{
|
{
|
||||||
uint256 hash; int32_t i;
|
uint256 hash; int32_t i;
|
||||||
@@ -1136,7 +1137,11 @@ void static RandomXMiner()
|
|||||||
|
|
||||||
// Create new block
|
// Create new block
|
||||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
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 we don't have a valid chain tip to work from, wait and try again.
|
||||||
if (pindexPrev == nullptr) {
|
if (pindexPrev == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user