diff --git a/src/miner.cpp b/src/miner.cpp index 16c18146b..72d6d04df 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1102,6 +1102,14 @@ void static RandomXMiner() // Create new block unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.LastTip(); + + // If we don't have a valid chain tip to work from, wait and try again. + if (pindexPrev == nullptr) { + fprintf(stderr,"%s: null pindexPrev, trying again...\n",__func__); + MilliSleep(1000); + continue; + } + if ( Mining_height != pindexPrev->GetHeight()+1 ) { Mining_height = pindexPrev->GetHeight()+1; @@ -1460,6 +1468,14 @@ void static BitcoinMiner() // unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.LastTip(); + + // If we don't have a valid chain tip to work from, wait and try again. + if (pindexPrev == nullptr) { + fprintf(stderr,"%s: null pindexPrev, trying again...\n",__func__); + MilliSleep(1000); + continue; + } + if ( Mining_height != pindexPrev->GetHeight()+1 ) { Mining_height = pindexPrev->GetHeight()+1;