Ensure pindexPrev is not null before mining against it in both BitcoinMiner and RandomXMiner
This commit is contained in:
@@ -1102,6 +1102,14 @@ 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 = 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 )
|
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
||||||
{
|
{
|
||||||
Mining_height = pindexPrev->GetHeight()+1;
|
Mining_height = pindexPrev->GetHeight()+1;
|
||||||
@@ -1460,6 +1468,14 @@ void static BitcoinMiner()
|
|||||||
//
|
//
|
||||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
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 )
|
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
||||||
{
|
{
|
||||||
Mining_height = pindexPrev->GetHeight()+1;
|
Mining_height = pindexPrev->GetHeight()+1;
|
||||||
|
|||||||
Reference in New Issue
Block a user