MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / LoadGenesisBlock

Method LoadGenesisBlock

src/validation.cpp:4587–4610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4585}
4586
4587bool CChainState::LoadGenesisBlock(const CChainParams& chainparams)
4588{
4589 LOCK(cs_main);
4590
4591 // Check whether we're already initialized by checking for genesis in
4592 // mapBlockIndex. Note that we can't use chainActive here, since it is
4593 // set based on the coins db, not the block index db, which is the only
4594 // thing loaded at this point.
4595 if (mapBlockIndex.count(chainparams.GenesisBlock().GetHash()))
4596 return true;
4597
4598 try {
4599 CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock());
4600 CDiskBlockPos blockPos = SaveBlockToDisk(block, 0, chainparams, nullptr);
4601 if (blockPos.IsNull())
4602 return error("%s: writing genesis block to disk failed", __func__);
4603 CBlockIndex *pindex = AddToBlockIndex(block);
4604 ReceivedBlockTransactions(block, pindex, blockPos, chainparams.GetConsensus());
4605 } catch (const std::runtime_error& e) {
4606 return error("%s: failed to write genesis block: %s", __func__, e.what());
4607 }
4608
4609 return true;
4610}
4611
4612bool LoadGenesisBlock(const CChainParams& chainparams)
4613{

Callers 1

LoadGenesisBlockFunction · 0.80

Calls 6

SaveBlockToDiskFunction · 0.85
errorFunction · 0.85
whatMethod · 0.80
countMethod · 0.45
GetHashMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected