| 1437 | } |
| 1438 | |
| 1439 | Block 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 | |
| 1461 | VerifiedBlockRef BlockChain::verifyBlock(bytesConstRef _block, std::function<void(Exception&)> const& _onBad, ImportRequirements::value _ir) const |
| 1462 | { |