|
|
@ -2679,7 +2679,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */ |
|
|
|
/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */ |
|
|
|
bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos) |
|
|
|
static bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos, const Consensus::Params& consensusParams) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pindexNew->nTx = block.vtx.size(); |
|
|
|
pindexNew->nTx = block.vtx.size(); |
|
|
|
pindexNew->nChainTx = 0; |
|
|
|
pindexNew->nChainTx = 0; |
|
|
@ -2687,7 +2687,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl |
|
|
|
pindexNew->nDataPos = pos.nPos; |
|
|
|
pindexNew->nDataPos = pos.nPos; |
|
|
|
pindexNew->nUndoPos = 0; |
|
|
|
pindexNew->nUndoPos = 0; |
|
|
|
pindexNew->nStatus |= BLOCK_HAVE_DATA; |
|
|
|
pindexNew->nStatus |= BLOCK_HAVE_DATA; |
|
|
|
if (IsWitnessEnabled(pindexNew->pprev, Params().GetConsensus())) { |
|
|
|
if (IsWitnessEnabled(pindexNew->pprev, consensusParams)) { |
|
|
|
pindexNew->nStatus |= BLOCK_OPT_WITNESS; |
|
|
|
pindexNew->nStatus |= BLOCK_OPT_WITNESS; |
|
|
|
} |
|
|
|
} |
|
|
|
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); |
|
|
|
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); |
|
|
@ -3209,7 +3209,7 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation |
|
|
|
if (dbp == NULL) |
|
|
|
if (dbp == NULL) |
|
|
|
if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) |
|
|
|
if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) |
|
|
|
AbortNode(state, "Failed to write block"); |
|
|
|
AbortNode(state, "Failed to write block"); |
|
|
|
if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) |
|
|
|
if (!ReceivedBlockTransactions(block, state, pindex, blockPos, chainparams.GetConsensus())) |
|
|
|
return error("AcceptBlock(): ReceivedBlockTransactions failed"); |
|
|
|
return error("AcceptBlock(): ReceivedBlockTransactions failed"); |
|
|
|
} catch (const std::runtime_error& e) { |
|
|
|
} catch (const std::runtime_error& e) { |
|
|
|
return AbortNode(state, std::string("System error: ") + e.what()); |
|
|
|
return AbortNode(state, std::string("System error: ") + e.what()); |
|
|
@ -3840,7 +3840,7 @@ bool InitBlockIndex(const CChainParams& chainparams) |
|
|
|
if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) |
|
|
|
if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) |
|
|
|
return error("LoadBlockIndex(): writing genesis block to disk failed"); |
|
|
|
return error("LoadBlockIndex(): writing genesis block to disk failed"); |
|
|
|
CBlockIndex *pindex = AddToBlockIndex(block); |
|
|
|
CBlockIndex *pindex = AddToBlockIndex(block); |
|
|
|
if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) |
|
|
|
if (!ReceivedBlockTransactions(block, state, pindex, blockPos, chainparams.GetConsensus())) |
|
|
|
return error("LoadBlockIndex(): genesis block not accepted"); |
|
|
|
return error("LoadBlockIndex(): genesis block not accepted"); |
|
|
|
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
|
|
|
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
|
|
|
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); |
|
|
|
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); |
|
|
|