Remove option to load new blocks from ConnectTip

This commit is contained in:
Kris Nuttycombe 2020-04-06 14:40:56 -06:00
parent caea54013e
commit 2013b35e3e
1 changed files with 12 additions and 8 deletions

View File

@ -3212,15 +3212,9 @@ uint64_t nNotifiedSequence = 0;
*/
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
{
assert(pindexNew->pprev == chainActive.Tip());
assert(pblock && pindexNew->pprev == chainActive.Tip());
// Read block from disk.
int64_t nTime1 = GetTimeMicros();
CBlock block;
if (!pblock) {
if (!ReadBlockFromDisk(block, pindexNew, chainparams.GetConsensus()))
return AbortNode(state, "Failed to read block");
pblock = █
}
// Apply the block atomically to the chain state.
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
int64_t nTime3;
@ -3431,7 +3425,17 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
// Connect new blocks.
BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) {
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) {
const CBlock* pconnectBlock = pblock;
CBlock block;
if (pindexConnect != pindexMostWork) {
if (!ReadBlockFromDisk(block, pindexConnect, chainparams.GetConsensus()))
return AbortNode(state, "Failed to read block");
pconnectBlock = █
} else {
pconnectBlock = pblock;
}
if (!ConnectTip(state, chainparams, pindexConnect, pconnectBlock)) {
if (state.IsInvalid()) {
// The block violates a consensus rule.
if (!state.CorruptionPossible())