mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Switch reindexing to AcceptBlock in-loop and ActivateBestChain afterwards
This commit is contained in:
13
src/main.cpp
13
src/main.cpp
@@ -3402,7 +3402,8 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, const CCha
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
CBlockIndex *&pindex = *ppindex;
|
||||
CBlockIndex *pindexDummy = NULL;
|
||||
CBlockIndex *&pindex = ppindex ? *ppindex : pindexDummy;
|
||||
|
||||
if (!AcceptBlockHeader(block, state, chainparams, &pindex))
|
||||
return false;
|
||||
@@ -4037,13 +4038,14 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
||||
|
||||
// process in case the block isn't known yet
|
||||
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) {
|
||||
LOCK(cs_main);
|
||||
CValidationState state;
|
||||
if (ProcessNewBlock(state, chainparams, NULL, &block, true, dbp))
|
||||
if (AcceptBlock(block, state, chainparams, NULL, true, dbp))
|
||||
nLoaded++;
|
||||
if (state.IsError())
|
||||
break;
|
||||
} else if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex[hash]->nHeight % 1000 == 0) {
|
||||
LogPrintf("Block Import: already had block %s at height %d\n", hash.ToString(), mapBlockIndex[hash]->nHeight);
|
||||
LogPrint("reindex", "Block Import: already had block %s at height %d\n", hash.ToString(), mapBlockIndex[hash]->nHeight);
|
||||
}
|
||||
|
||||
// Recursively process earlier encountered successors of this block
|
||||
@@ -4057,10 +4059,11 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
||||
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
||||
if (ReadBlockFromDisk(block, it->second, chainparams.GetConsensus()))
|
||||
{
|
||||
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||
LogPrint("reindex", "%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||
head.ToString());
|
||||
LOCK(cs_main);
|
||||
CValidationState dummy;
|
||||
if (ProcessNewBlock(dummy, chainparams, NULL, &block, true, &it->second))
|
||||
if (AcceptBlock(block, dummy, chainparams, NULL, true, &it->second))
|
||||
{
|
||||
nLoaded++;
|
||||
queue.push_back(block.GetHash());
|
||||
|
||||
Reference in New Issue
Block a user