Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,065 Lines • ▼ Show 20 Lines | bool CChainState::LoadGenesisBlock(const CChainParams &chainparams) { | ||||
// mapBlockIndex. Note that we can't use chainActive here, since it is | // mapBlockIndex. Note that we can't use chainActive here, since it is | ||||
// set based on the coins db, not the block index db, which is the only | // set based on the coins db, not the block index db, which is the only | ||||
// thing loaded at this point. | // thing loaded at this point. | ||||
if (mapBlockIndex.count(chainparams.GenesisBlock().GetHash())) { | if (mapBlockIndex.count(chainparams.GenesisBlock().GetHash())) { | ||||
return true; | return true; | ||||
} | } | ||||
try { | try { | ||||
CBlock &block = const_cast<CBlock &>(chainparams.GenesisBlock()); | const CBlock &block = chainparams.GenesisBlock(); | ||||
FlatFilePos blockPos = SaveBlockToDisk(block, 0, chainparams, nullptr); | FlatFilePos blockPos = SaveBlockToDisk(block, 0, chainparams, nullptr); | ||||
if (blockPos.IsNull()) { | if (blockPos.IsNull()) { | ||||
return error("%s: writing genesis block to disk failed", __func__); | return error("%s: writing genesis block to disk failed", __func__); | ||||
} | } | ||||
CBlockIndex *pindex = AddToBlockIndex(block); | CBlockIndex *pindex = AddToBlockIndex(block); | ||||
CValidationState state; | CValidationState state; | ||||
if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) { | if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) { | ||||
return error("%s: genesis block not accepted (%s)", __func__, | return error("%s: genesis block not accepted (%s)", __func__, | ||||
▲ Show 20 Lines • Show All 689 Lines • Show Last 20 Lines |