|
|
@ -2915,9 +2915,8 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ProcessNewBlock(CValidationState &state, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) |
|
|
|
bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos* dbp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
|
|
|
|
// Preliminary checks
|
|
|
|
// Preliminary checks
|
|
|
|
bool checked = CheckBlock(*pblock, state); |
|
|
|
bool checked = CheckBlock(*pblock, state); |
|
|
|
|
|
|
|
|
|
|
@ -2946,9 +2945,8 @@ bool ProcessNewBlock(CValidationState &state, const CNode* pfrom, const CBlock* |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex * const pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot) |
|
|
|
bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CChainParams& chainparams = Params(); |
|
|
|
|
|
|
|
AssertLockHeld(cs_main); |
|
|
|
AssertLockHeld(cs_main); |
|
|
|
assert(pindexPrev && pindexPrev == chainActive.Tip()); |
|
|
|
assert(pindexPrev && pindexPrev == chainActive.Tip()); |
|
|
|
if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, block.GetHash())) |
|
|
|
if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, block.GetHash())) |
|
|
@ -3488,7 +3486,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) |
|
|
|
// process in case the block isn't known yet
|
|
|
|
// process in case the block isn't known yet
|
|
|
|
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) { |
|
|
|
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) { |
|
|
|
CValidationState state; |
|
|
|
CValidationState state; |
|
|
|
if (ProcessNewBlock(state, NULL, &block, true, dbp)) |
|
|
|
if (ProcessNewBlock(state, chainparams, NULL, &block, true, dbp)) |
|
|
|
nLoaded++; |
|
|
|
nLoaded++; |
|
|
|
if (state.IsError()) |
|
|
|
if (state.IsError()) |
|
|
|
break; |
|
|
|
break; |
|
|
@ -3510,7 +3508,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) |
|
|
|
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(), |
|
|
|
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(), |
|
|
|
head.ToString()); |
|
|
|
head.ToString()); |
|
|
|
CValidationState dummy; |
|
|
|
CValidationState dummy; |
|
|
|
if (ProcessNewBlock(dummy, NULL, &block, true, &it->second)) |
|
|
|
if (ProcessNewBlock(dummy, chainparams, NULL, &block, true, &it->second)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nLoaded++; |
|
|
|
nLoaded++; |
|
|
|
queue.push_back(block.GetHash()); |
|
|
|
queue.push_back(block.GetHash()); |
|
|
@ -4547,7 +4545,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
// Such an unrequested block may still be processed, subject to the
|
|
|
|
// Such an unrequested block may still be processed, subject to the
|
|
|
|
// conditions in AcceptBlock().
|
|
|
|
// conditions in AcceptBlock().
|
|
|
|
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); |
|
|
|
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); |
|
|
|
ProcessNewBlock(state, pfrom, &block, forceProcessing, NULL); |
|
|
|
ProcessNewBlock(state, chainparams, pfrom, &block, forceProcessing, NULL); |
|
|
|
int nDoS; |
|
|
|
int nDoS; |
|
|
|
if (state.IsInvalid(nDoS)) { |
|
|
|
if (state.IsInvalid(nDoS)) { |
|
|
|
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
|
|
|
|
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
|
|
|
|