MCPcopy Create free account
hub / github.com/LUX-Core/lux / genesisBlock

Method genesisBlock

src/cpp-ethereum/libethereum/BlockChain.cpp:1439–1459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1437}
1438
1439Block BlockChain::genesisBlock(OverlayDB const& _db) const
1440{
1441 h256 r = BlockHeader(m_params.genesisBlock()).stateRoot();
1442 Block ret(*this, _db, BaseState::Empty);
1443 if (!_db.exists(r))
1444 {
1445 ret.noteChain(*this);
1446 dev::eth::commit(m_params.genesisState, ret.mutableState().m_state); // bit horrible. maybe consider a better way of constructing it?
1447 ret.mutableState().db().commit(); // have to use this db() since it's the one that has been altered with the above commit.
1448 if (ret.mutableState().rootHash() != r)
1449 {
1450 cwarn << "Hinted genesis block's state root hash is incorrect!";
1451 cwarn << "Hinted" << r << ", computed" << ret.mutableState().rootHash();
1452 // TODO: maybe try to fix it by altering the m_params's genesis block?
1453 exit(-1);
1454 }
1455 }
1456 ret.m_previousBlock = BlockHeader(m_params.genesisBlock());
1457 ret.resetCurrent();
1458 return ret;
1459}
1460
1461VerifiedBlockRef BlockChain::verifyBlock(bytesConstRef _block, std::function<void(Exception&)> const& _onBad, ImportRequirements::value _ir) const
1462{

Callers 13

initMethod · 0.45
reopenChainMethod · 0.45
BlockChain.cppFile · 0.45
openMethod · 0.45
blockMethod · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BlockChainLoaderMethod · 0.45
mineMethod · 0.45
resetMethod · 0.45

Calls 8

noteChainMethod · 0.80
resetCurrentMethod · 0.80
commitFunction · 0.70
BlockHeaderClass · 0.50
existsMethod · 0.45
commitMethod · 0.45
dbMethod · 0.45
rootHashMethod · 0.45

Tested by 8

BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BlockChainLoaderMethod · 0.36
mineMethod · 0.36
resetMethod · 0.36
addBlockMethod · 0.36