From db65d92df4096f278b8a6d9a6375a52e5a1f5cc2 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Mon, 6 Apr 2020 14:48:25 -0600 Subject: [PATCH] Make condition closer to original, Fix incorrect comment. --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4855e29f2..7fe9aa2d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3213,7 +3213,6 @@ uint64_t nNotifiedSequence = 0; bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock) { assert(pblock && pindexNew->pprev == chainActive.Tip()); - // Read block from disk. int64_t nTime1 = GetTimeMicros(); // Apply the block atomically to the chain state. int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1; @@ -3425,14 +3424,15 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c // Connect new blocks. BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { - const CBlock* pconnectBlock = pblock; + const CBlock* pconnectBlock; CBlock block; - if (pindexConnect != pindexMostWork) { + if (pindexConnect == pindexMostWork) { + pconnectBlock = pblock; + } else { + // read the block to be connected from disk if (!ReadBlockFromDisk(block, pindexConnect, chainparams.GetConsensus())) return AbortNode(state, "Failed to read block"); pconnectBlock = █ - } else { - pconnectBlock = pblock; } if (!ConnectTip(state, chainparams, pindexConnect, pconnectBlock)) {