| 4585 | } |
| 4586 | |
| 4587 | bool 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 | |
| 4612 | bool LoadGenesisBlock(const CChainParams& chainparams) |
| 4613 | { |
no test coverage detected