Merge pull request #5853 from nuttycom/bug/miner_guard_chainactive
Ensure pindexPrev is not null before mining against it.
This commit is contained in:
commit
d0a30cd0d2
|
@ -922,7 +922,17 @@ void static BitcoinMiner(const CChainParams& chainparams)
|
||||||
// Create new block
|
// Create new block
|
||||||
//
|
//
|
||||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
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));
|
unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(chainparams, minerAddress));
|
||||||
if (!pblocktemplate.get())
|
if (!pblocktemplate.get())
|
||||||
|
|
Loading…
Reference in New Issue