Browse Source

Fix mining.

cl-refactor
Gav Wood 10 years ago
parent
commit
5cac25e2ef
  1. 27
      ethminer/main.cpp
  2. 9
      libethcore/Ethash.cpp
  3. 1
      libethcore/Ethash.h

27
ethminer/main.cpp

@ -223,6 +223,7 @@ void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod)
(void)_recheckPeriod;
#if ETH_JSONRPC || !ETH_TRUE
jsonrpc::HttpClient client(_remote);
Farm rpc(client);
GenericFarm<Ethash> f;
if (_m == MinerType::CPU)
@ -254,17 +255,31 @@ void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod)
current.headerHash = hh;
current.seedHash = h256(v[1].asString());
current.boundary = h256(fromHex(v[2].asString()), h256::AlignRight);
cnote << "Got work package:" << current.headerHash << " < " << current.boundary;
cnote << "Got work package:";
cnote << " Header-hash:" << current.headerHash.hex();
cnote << " Seedhash:" << current.seedHash.hex();
cnote << " Target: " << h256(current.boundary).hex();
f.setWork(current);
}
this_thread::sleep_for(chrono::milliseconds(_recheckPeriod));
}
cnote << "Solution found; submitting [" << solution.nonce << "," << current.headerHash << "," << solution.mixHash << "] to" << _remote << "...";
bool ok = rpc.eth_submitWork("0x" + toString(solution.nonce), "0x" + toString(current.headerHash), "0x" + toString(solution.mixHash));
if (ok)
clog(HappyChannel) << "Submitted and accepted.";
cnote << "Solution found; Submitting to" << _remote << "...";
cnote << " Nonce:" << solution.nonce.hex();
cnote << " Mixhash:" << solution.mixHash.hex();
cnote << " Header-hash:" << current.headerHash.hex();
cnote << " Seedhash:" << current.seedHash.hex();
cnote << " Target: " << h256(current.boundary).hex();
cnote << " Ethash: " << h256(EthashAux::eval(EthashAux::number(current.seedHash), current.headerHash, solution.nonce).value).hex();
if (EthashAux::eval(EthashAux::number(current.seedHash), current.headerHash, solution.nonce).value < current.boundary)
{
bool ok = rpc.eth_submitWork("0x" + toString(solution.nonce), "0x" + toString(current.headerHash), "0x" + toString(solution.mixHash));
if (ok)
clog(HappyChannel) << "Submitted and accepted.";
else
clog(SadChannel) << "Not accepted.";
}
else
clog(SadChannel) << "Not accepted.";
cwarn << "FAILURE: GPU gave incorrect result!";
current.reset();
}
catch (jsonrpc::JsonRpcException&)

9
libethcore/Ethash.cpp

@ -72,7 +72,6 @@ Ethash::WorkPackage Ethash::package(BlockInfo const& _bi)
ret.boundary = _bi.boundary();
ret.headerHash = _bi.headerHash(WithoutNonce);
ret.seedHash = _bi.seedHash();
ret.blockNumber = (uint64_t) _bi.number;
return ret;
}
@ -135,7 +134,7 @@ void Ethash::CPUMiner::workLoop()
WorkPackage w = work();
auto dag = EthashAux::full(w.blockNumber);
auto dag = EthashAux::full(EthashAux::number(w.seedHash));
h256 boundary = w.boundary;
unsigned hashCount = 1;
for (; !shouldStop(); tryNonce++, hashCount++)
@ -284,7 +283,7 @@ Ethash::GPUMiner::~GPUMiner()
bool Ethash::GPUMiner::report(uint64_t _nonce)
{
Nonce n = (Nonce)(u64)_nonce;
Result r = EthashAux::eval(work().blockNumber, work().headerHash, n);
Result r = EthashAux::eval(EthashAux::number(work().seedHash), work().headerHash, n);
if (r.value < work().boundary)
return submitProof(Solution{n, r.mixHash});
return false;
@ -310,9 +309,9 @@ void Ethash::GPUMiner::workLoop()
unsigned device = instances() > 1 ? index() : s_deviceId;
if (!EthashAux::computeFull(w.blockNumber))
if (!EthashAux::computeFull(EthashAux::number(w.seedHash)))
return;
EthashAux::FullType dag = EthashAux::full(w.blockNumber);
EthashAux::FullType dag = EthashAux::full(EthashAux::number(w.seedHash));
bytesConstRef dagData = dag->data();
m_miner->init(dagData.data(), dagData.size(), 32, s_platformId, device);
}

1
libethcore/Ethash.h

@ -67,7 +67,6 @@ public:
h256 boundary;
h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
h256 seedHash; /// LTODO: IS this needed now that we use the block number instead?
uint64_t blockNumber;
};
static const WorkPackage NullWorkPackage;

Loading…
Cancel
Save