mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Assets?: Make sure there's a chainActive.Tip() before calling some functions
This commit is contained in:
parent
aee6723f72
commit
6d72a1e403
1 changed files with 6 additions and 4 deletions
10
src/main.cpp
10
src/main.cpp
|
|
@ -1453,7 +1453,8 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip)
|
|||
pindexBestForkBase = pfork;
|
||||
}
|
||||
|
||||
CheckForkWarningConditions();
|
||||
if (chainActive.Tip())
|
||||
CheckForkWarningConditions();
|
||||
}
|
||||
|
||||
// Requires cs_main.
|
||||
|
|
@ -1488,7 +1489,8 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
|
|||
LogPrintf("InvalidChainFound: current best=%s height=%d log2_work=%.8g date=%s\n",
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()));
|
||||
CheckForkWarningConditions();
|
||||
if (chainActive.Tip())
|
||||
CheckForkWarningConditions();
|
||||
}
|
||||
|
||||
void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state) {
|
||||
|
|
@ -3029,7 +3031,7 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis
|
|||
return error("%s : AcceptBlock FAILED", __func__);
|
||||
}
|
||||
|
||||
if (!ActivateBestChain(state, pblock))
|
||||
if (chainActive.Tip() && !ActivateBestChain(state, pblock))
|
||||
return error("%s : ActivateBestChain failed", __func__);
|
||||
|
||||
return true;
|
||||
|
|
@ -3376,7 +3378,7 @@ bool InitBlockIndex() {
|
|||
CBlockIndex *pindex = AddToBlockIndex(block);
|
||||
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
|
||||
return error("LoadBlockIndex() : genesis block not accepted");
|
||||
if (!ActivateBestChain(state, &block))
|
||||
if (chainActive.Tip() && !ActivateBestChain(state, &block))
|
||||
return error("LoadBlockIndex() : genesis block cannot be activated");
|
||||
// Force a chainstate write so that when we VerifyDB in a moment, it doesnt check stale data
|
||||
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue