Ensure pindexPrev is not null before mining against it.

This commit is contained in:
Kris Nuttycombe 2022-04-08 14:54:23 -06:00
parent 2c13a41334
commit cc8b3f9657
1 changed files with 11 additions and 1 deletions

View File

@ -922,7 +922,17 @@ void static BitcoinMiner(const CChainParams& chainparams)
// Create new block
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
CBlockIndex* pindexPrev;
{
LOCK(cs_main);
pindexPrev = chainActive.Tip();
}
// If we don't have a valid chain tip to work from, wait and try again.
if (pindexPrev == nullptr) {
MilliSleep(1000);
continue;
}
unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(chainparams, minerAddress));
if (!pblocktemplate.get())