Browse Source

Avoid mining on empty blocks.

Protocol bump.
cl-refactor
Gav Wood 11 years ago
parent
commit
f49b6b9476
  1. 9
      alethzero/Main.ui
  2. 6
      alethzero/MainWin.cpp
  3. 2
      alethzero/MainWin.h
  4. 2
      libethcore/CommonEth.cpp
  5. 8
      libethereum/Client.cpp
  6. 5
      libethereum/Client.h
  7. 2
      libethereum/State.cpp

9
alethzero/Main.ui

@ -184,7 +184,7 @@
<addaction name="paranoia"/>
<addaction name="killBlockchain"/>
<addaction name="inject"/>
<addaction name="clearPending"/>
<addaction name="forceMining"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Network"/>
@ -1559,9 +1559,12 @@ font-size: 14pt</string>
<string>Ctrl+F10</string>
</property>
</action>
<action name="clearPending">
<action name="forceMining">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Clear Pending</string>
<string>&amp;Force Mining</string>
</property>
</action>
<action name="dumpTraceStorage">

6
alethzero/MainWin.cpp

@ -327,9 +327,9 @@ void Main::onNewPending()
refreshAccounts();
}
void Main::on_clearPending_triggered()
void Main::on_forceMining_triggered()
{
m_client->clearPending();
m_client->setForceMining(ui->forceMining->isChecked());
}
void Main::load(QString _s)
@ -485,6 +485,7 @@ void Main::writeSettings()
s.setValue("upnp", ui->upnp->isChecked());
s.setValue("forceAddress", ui->forceAddress->text());
s.setValue("usePast", ui->usePast->isChecked());
s.setValue("forceMining", ui->forceMining->isChecked());
s.setValue("paranoia", ui->paranoia->isChecked());
s.setValue("showAll", ui->showAll->isChecked());
s.setValue("showAllAccounts", ui->showAllAccounts->isChecked());
@ -529,6 +530,7 @@ void Main::readSettings()
ui->upnp->setChecked(s.value("upnp", true).toBool());
ui->forceAddress->setText(s.value("forceAddress", "").toString());
ui->usePast->setChecked(s.value("usePast", true).toBool());
ui->forceMining->setChecked(s.value("forceMining", false).toBool());
ui->paranoia->setChecked(s.value("paranoia", false).toBool());
ui->showAll->setChecked(s.value("showAll", false).toBool());
ui->showAllAccounts->setChecked(s.value("showAllAccounts", false).toBool());

2
alethzero/MainWin.h

@ -125,7 +125,7 @@ private slots:
void on_showAllAccounts_triggered() { refreshAccounts(); }
void on_loadJS_triggered();
void on_blockChainFilter_textChanged();
void on_clearPending_triggered();
void on_forceMining_triggered();
void on_dumpTrace_triggered();
void on_dumpTraceStorage_triggered();
void on_dumpTracePretty_triggered();

2
libethcore/CommonEth.cpp

@ -29,7 +29,7 @@ using namespace eth;
//#define ETH_ADDRESS_DEBUG 1
const unsigned eth::c_protocolVersion = 24;
const unsigned eth::c_protocolVersion = 25;
const unsigned eth::c_databaseVersion = 1;
static const vector<pair<u256, string>> g_units =

8
libethereum/Client.cpp

@ -388,7 +388,7 @@ void Client::work(bool _justQueue)
h256Set changeds;
// Do some mining.
if (!_justQueue)
if (!_justQueue && (m_pendingCount || m_forceMining))
{
// TODO: Separate "Miner" object.
@ -455,6 +455,11 @@ void Client::work(bool _justQueue)
this_thread::sleep_for(chrono::milliseconds(100));
}
}
else
{
cwork << "SLEEP";
this_thread::sleep_for(chrono::milliseconds(100));
}
// Synchronise state to block chain.
// This should remove any transactions on our queue that are included within our state.
@ -503,6 +508,7 @@ void Client::work(bool _justQueue)
cnote << "Additional transaction ready: Restarting mining operation.";
m_restartMining = true;
}
m_pendingCount = m_postMine.pending().size();
}
cwork << "noteChanged" << changeds.size() << "items";

5
libethereum/Client.h

@ -295,6 +295,9 @@ public:
/// Get and clear the mining history.
std::list<MineInfo> miningHistory() { auto ret = m_mineHistory; m_mineHistory.clear(); return ret; }
bool forceMining() const { return m_forceMining; }
void setForceMining(bool _enable) { m_forceMining = _enable; }
/// Clears pending transactions. Just for debug use.
void clearPending();
@ -347,9 +350,11 @@ private:
bool m_paranoia = false;
bool m_doMine = false; ///< Are we supposed to be mining?
bool m_forceMining = false; ///< Mine even when there are no transactions pending?
MineProgress m_mineProgress;
std::list<MineInfo> m_mineHistory;
mutable bool m_restartMining = false;
mutable unsigned m_pendingCount = 0;
mutable std::mutex m_filterLock;
std::map<h256, InstalledFilter> m_filters;

2
libethereum/State.cpp

@ -681,7 +681,7 @@ void State::commitToMine(BlockChain const& _bc)
{
uncommitToMine();
cnote << "Commiting to mine on block" << m_previousBlock.hash;
cnote << "Committing to mine on block" << m_previousBlock.hash;
#ifdef ETH_PARANOIA
commit();
cnote << "Pre-reward stateRoot:" << m_state.root();

Loading…
Cancel
Save