Browse Source

Remote mining fixes.

cl-refactor
Gav Wood 10 years ago
parent
commit
ce205f382c
  1. 2
      alethzero/MainWin.cpp
  2. 2
      ethminer/MinerAux.h
  3. 2
      libethereum/BlockQueue.h
  4. 8
      libethereum/Client.cpp
  5. 3
      libethereum/Client.h

2
alethzero/MainWin.cpp

@ -1166,7 +1166,7 @@ void Main::on_turboMining_triggered()
void Main::refreshBlockChain() void Main::refreshBlockChain()
{ {
if (!ui->blocks->isVisible() || !isVisible()) if (!ui->blocks->isVisible() && isVisible())
return; return;
DEV_TIMED_FUNCTION_ABOVE(500); DEV_TIMED_FUNCTION_ABOVE(500);

2
ethminer/MinerAux.h

@ -419,6 +419,8 @@ private:
Json::Value v = rpc.eth_getWork(); Json::Value v = rpc.eth_getWork();
h256 hh(v[0].asString()); h256 hh(v[0].asString());
h256 newSeedHash(v[1].asString()); h256 newSeedHash(v[1].asString());
if (current.seedHash != newSeedHash)
cnote << "Grabbing DAG for" << newSeedHash;
if (!(dag = EthashAux::full(newSeedHash, true, [&](unsigned _pc){ cout << "\rCreating DAG. " << _pc << "% done..." << flush; return 0; }))) if (!(dag = EthashAux::full(newSeedHash, true, [&](unsigned _pc){ cout << "\rCreating DAG. " << _pc << "% done..." << flush; return 0; })))
BOOST_THROW_EXCEPTION(DAGCreationFailure()); BOOST_THROW_EXCEPTION(DAGCreationFailure());
if (hh != current.headerHash) if (hh != current.headerHash)

2
libethereum/BlockQueue.h

@ -94,7 +94,7 @@ public:
void retryAllUnknown(); void retryAllUnknown();
/// Get information on the items queued. /// Get information on the items queued.
std::pair<unsigned, unsigned> items() const { ReadGuard l(m_lock); return std::make_pair(m_verified.size(), m_unknown.size()); } std::pair<unsigned, unsigned> items() const { ReadGuard l(m_lock); return std::make_pair(m_readySet.size(), m_unknownSet.size()); }
/// Clear everything. /// Clear everything.
void clear() { WriteGuard l(m_lock); DEV_INVARIANT_CHECK; Guard l2(m_verification); m_readySet.clear(); m_drainingSet.clear(); m_verified.clear(); m_unverified.clear(); m_unknownSet.clear(); m_unknown.clear(); m_future.clear(); } void clear() { WriteGuard l(m_lock); DEV_INVARIANT_CHECK; Guard l2(m_verification); m_readySet.clear(); m_drainingSet.clear(); m_verified.clear(); m_unverified.clear(); m_unknownSet.clear(); m_unknown.clear(); m_future.clear(); }

8
libethereum/Client.cpp

@ -455,8 +455,13 @@ ProofOfWork::WorkPackage Client::getWork()
{ {
// lock the work so a later submission isn't invalidated by processing a transaction elsewhere. // lock the work so a later submission isn't invalidated by processing a transaction elsewhere.
// this will be reset as soon as a new block arrives, allowing more transactions to be processed. // this will be reset as soon as a new block arrives, allowing more transactions to be processed.
bool oldShould = shouldServeWork();
m_lastGetWork = chrono::system_clock::now(); m_lastGetWork = chrono::system_clock::now();
m_remoteWorking = true; m_remoteWorking = true;
// if this request has made us bother to serve work, prep it now.
if (!oldShould && shouldServeWork())
onPostStateChanged();
return ProofOfWork::package(m_miningInfo); return ProofOfWork::package(m_miningInfo);
} }
@ -612,7 +617,8 @@ bool Client::remoteActive() const
void Client::onPostStateChanged() void Client::onPostStateChanged()
{ {
cnote << "Post state changed"; cnote << "Post state changed";
if (isMining() || remoteActive())
if (m_bq.items().first == 0 && (isMining() || remoteActive()))
{ {
cnote << "Restarting mining..."; cnote << "Restarting mining...";
DEV_WRITE_GUARDED(x_working) DEV_WRITE_GUARDED(x_working)

3
libethereum/Client.h

@ -274,6 +274,9 @@ private:
/// Ticks various system-level objects. /// Ticks various system-level objects.
void tick(); void tick();
/// @returns true only if it's worth bothering to prep the mining block.
bool shouldServeWork() const { return m_bq.items().first == 0 && (isMining() || remoteActive()); }
VersionChecker m_vc; ///< Dummy object to check & update the protocol version. VersionChecker m_vc; ///< Dummy object to check & update the protocol version.
CanonBlockChain m_bc; ///< Maintains block database. CanonBlockChain m_bc; ///< Maintains block database.
BlockQueue m_bq; ///< Maintains a list of incoming blocks not yet on the blockchain (to be imported). BlockQueue m_bq; ///< Maintains a list of incoming blocks not yet on the blockchain (to be imported).

Loading…
Cancel
Save