From 3fa0fd80c80cb3c2a69907c1b0b696a86eb2d0d0 Mon Sep 17 00:00:00 2001 From: arkpar Date: Sat, 31 Jan 2015 23:54:47 +0100 Subject: [PATCH] mix: proper mining --- libethereum/Executive.cpp | 2 +- mix/ClientModel.cpp | 12 ++++++++++-- mix/MixClient.cpp | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index cea7d21f4..5208fc8bd 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -68,7 +68,7 @@ bool Executive::setup(bytesConstRef _rlp) if (m_t.gas() < gasCost) { - clog(StateDetail) << "Not enough gas to pay for the transaction: Require >" << gasCost << " Got" << m_t.gas(); + clog << "Not enough gas to pay for the transaction: Require >" << gasCost << " Got" << m_t.gas(); BOOST_THROW_EXCEPTION(OutOfGas() << RequirementError((bigint)gasCost, (bigint)m_t.gas())); } diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 914edf52d..7fe514c09 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -93,8 +93,16 @@ ClientModel::~ClientModel() QString ClientModel::apiCall(QString const& _message) { - m_rpcConnector->OnRequest(_message.toStdString(), nullptr); - return m_rpcConnector->response(); + try + { + m_rpcConnector->OnRequest(_message.toStdString(), nullptr); + return m_rpcConnector->response(); + } + catch (...) + { + std::cerr << boost::current_exception_diagnostic_information(); + return QString(); + } } void ClientModel::mine() diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index b5f92b4f9..0e95fa429 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -50,7 +50,7 @@ void MixClient::resetState(u256 _balance) Guard fl(m_filterLock); m_filters.clear(); m_watches.clear(); - m_state = eth::State(m_userAccount.address(), m_stateDB, BaseState::Empty); + m_state = eth::State(m_userAccount.address(), m_stateDB, BaseState::Genesis); m_state.addBalance(m_userAccount.address(), _balance); Block genesis; genesis.state = m_state; @@ -161,7 +161,10 @@ void MixClient::mine() { WriteGuard l(x_state); Block& block = m_blocks.back(); + m_state.mine(0, true); m_state.completeMine(); + m_state.commitToMine(BlockChain()); + m_state.cleanup(true); block.state = m_state; block.info = m_state.info(); block.hash = block.info.hash;