MCPcopy Create free account
hub / github.com/ElementsProject/elements / LoadGenesisBlock

Method LoadGenesisBlock

src/validation.cpp:4572–4596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4570}
4571
4572bool CChainState::LoadGenesisBlock()
4573{
4574 LOCK(cs_main);
4575
4576 // Check whether we're already initialized by checking for genesis in
4577 // m_blockman.m_block_index. Note that we can't use m_chain here, since it is
4578 // set based on the coins db, not the block index db, which is the only
4579 // thing loaded at this point.
4580 if (m_blockman.m_block_index.count(m_params.GenesisBlock().GetHash()))
4581 return true;
4582
4583 try {
4584 const CBlock& block = m_params.GenesisBlock();
4585 FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, m_chain, m_params, nullptr)};
4586 if (blockPos.IsNull()) {
4587 return error("%s: writing genesis block to disk failed", __func__);
4588 }
4589 CBlockIndex *pindex = m_blockman.AddToBlockIndex(block);
4590 ReceivedBlockTransactions(block, pindex, blockPos);
4591 } catch (const std::runtime_error& e) {
4592 return error("%s: failed to write genesis block: %s", __func__, e.what());
4593 }
4594
4595 return true;
4596}
4597
4598void CChainState::LoadExternalBlockFile(FILE* fileIn, FlatFilePos* dbp)
4599{

Callers 4

BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
LoadChainstateFunction · 0.80
ThreadImportFunction · 0.80

Calls 6

errorFunction · 0.85
countMethod · 0.80
SaveBlockToDiskMethod · 0.80
AddToBlockIndexMethod · 0.80
GetHashMethod · 0.45
IsNullMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64