Browse Source

mix: proper mining

cl-refactor
arkpar 10 years ago
parent
commit
3fa0fd80c8
  1. 2
      libethereum/Executive.cpp
  2. 12
      mix/ClientModel.cpp
  3. 5
      mix/MixClient.cpp

2
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()));
}

12
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()

5
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;

Loading…
Cancel
Save