Browse Source

Merge pull request #2527 from LefterisJP/respect_no_precompute

ensurePrecomputed should respect no_precompute argument V2
cl-refactor
Gav Wood 10 years ago
parent
commit
7bebb42551
  1. 1
      eth/main.cpp
  2. 1
      ethminer/MinerAux.h
  3. 4
      libethcore/EthashSealEngine.cpp
  4. 7
      libethereum/Client.cpp
  5. 2
      libethereum/Client.h

1
eth/main.cpp

@ -1700,6 +1700,7 @@ int main(int argc, char** argv)
c->setGasPricer(gasPricer);
c->setForceMining(forceMining);
// TODO: expose sealant interface.
c->setShouldPrecomputeDAG(m.shouldPrecompute());
c->setTurboMining(m.minerType() == MinerCLI::MinerType::GPU);
c->setAddress(beneficiary);
c->setNetworkId(networkId);

1
ethminer/MinerAux.h

@ -380,6 +380,7 @@ public:
};
MinerType minerType() const { return m_minerType; }
bool shouldPrecompute() const { return m_precompute; }
private:
void doInitDAG(unsigned _n)

4
libethcore/EthashSealEngine.cpp

@ -54,7 +54,9 @@ void EthashSealEngine::generateSeal(BlockInfo const& _bi)
m_farm.setWork(m_sealing);
m_farm.start(m_sealer);
m_farm.setWork(m_sealing); // TODO: take out one before or one after...
Ethash::ensurePrecomputed((unsigned)_bi.number());
bytes shouldPrecompute = option("precomputeDAG");
if (!shouldPrecompute.empty() && shouldPrecompute[0] == 1)
Ethash::ensurePrecomputed((unsigned)_bi.number());
}
void EthashSealEngine::onSealGenerated(std::function<void(bytes const&)> const& _f)

7
libethereum/Client.cpp

@ -443,6 +443,13 @@ void Client::setForceMining(bool _enable)
startMining();
}
void Client::setShouldPrecomputeDAG(bool _precompute)
{
bytes trueBytes {1};
bytes falseBytes {0};
sealEngine()->setOption("precomputeDAG", _precompute ? trueBytes: falseBytes);
}
bool Client::isMining() const
{
return Ethash::isWorking(m_sealEngine.get());

2
libethereum/Client.h

@ -140,6 +140,8 @@ public:
bool turboMining() const { return m_turboMining; }
/// Enable/disable GPU mining.
void setTurboMining(bool _enable = true) { m_turboMining = _enable; if (isMining()) startMining(); }
/// Enable/disable precomputing of the DAG for next epoch
void setShouldPrecomputeDAG(bool _precompute);
/// Check to see if we'd mine on an apparently bad chain.
bool mineOnBadChain() const { return m_mineOnBadChain; }

Loading…
Cancel
Save