Skip to content

Commit 741da6f

Browse files
fixed hash rate reporting error when more than one miner
1 parent 284cb11 commit 741da6f

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

ethminer/FarmClient.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class FarmClient : public jsonrpc::Client
112112
tx = CallMethod("eth_getTransactionReceipt", data);
113113
if (!tx.isNull())
114114
{
115-
string bidStatus = tx["status"].asString() == "0x1" ? " WON" : (tx["status"].asString() == "0x0" ? " LOST" : " ???");
115+
string bidStatus = tx["status"].asString() == "0x1" ? " won" : (tx["status"].asString() == "0x0" ? " lost" : " ???");
116116
LogD << "Miner " << miner.account.substr(0, 10) << bidStatus << ", block: "
117117
<< HexToInt(tx["blockNumber"].asString()) << ", tx=" << miner.txHash.substr(0, 10);
118118
m_biddingMiners.erase(m_biddingMiners.begin() + i);
@@ -233,12 +233,17 @@ class FarmClient : public jsonrpc::Client
233233
data.append(p);
234234
data.append("latest");
235235

236-
Json::Value result = CallMethod("eth_call", data);
237-
u256 balance = u256(result.asString()) / 100000000;
238-
if (result.isString()) {
236+
try
237+
{
238+
Json::Value result = CallMethod("eth_call", data);
239+
u256 balance = u256(result.asString()) / 100000000;
239240
return static_cast<uint64_t>(balance);
240-
} else
241-
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
241+
}
242+
catch (std::exception& e)
243+
{
244+
LogB << "Error in routine tokenBalance: " << e.what();
245+
return 0;
246+
}
242247
}
243248

244249
Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) {

ethminer/MinerAux.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ class MinerCLI
760760
unsigned farmRetries = 0;
761761
int maxRetries = failOverAvailable() ? m_maxFarmRetries : c_StopWorkAt;
762762
bool connectedToNode = false;
763+
string gasPriceBidding = ProgOpt::Get("0xBitcoin", "GasPriceBidding", "0");
763764

764765
LogS << "Connecting to node at " << _nodeURL + ":" + _rpcPort << " ...";
765766
jsonrpc::HttpClient client(_nodeURL + ":" + _rpcPort);
@@ -843,6 +844,10 @@ class MinerCLI
843844
recentChallenges.pop_back();
844845
challenge = _challenge;
845846
target = _target;
847+
848+
//target = h256(0x0000000080000000); // easy target for testing
849+
//target = (u256) target << 192;
850+
846851
LogB << "New challenge : " << toHex(_challenge).substr(0, 8);
847852
f.setWork_token(challenge, target);
848853
rpc.setChallenge(challenge);
@@ -854,7 +859,8 @@ class MinerCLI
854859
if (lastCheckTx.elapsedMilliseconds() > 1000)
855860
{
856861
rpc.checkPendingTransactions();
857-
rpc.txpoolScanner();
862+
if (gasPriceBidding == "1")
863+
rpc.txpoolScanner();
858864
lastCheckTx.restart();
859865
}
860866

libethash-cl/ethash_cl_miner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ bool ethash_cl_miner::configureGPU(
239239
_device.getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result);
240240
if (result >= requiredSize)
241241
{
242-
std::string s = string(_device.getInfo<CL_DEVICE_NAME>().c_str());
243-
LogS << "Found suitable OpenCL device [" << s << "] with " << result << " bytes of GPU memory";
242+
//std::string s = string(_device.getInfo<CL_DEVICE_NAME>().c_str());
243+
//LogS << "Found suitable OpenCL device [" << s << "] with " << result << " bytes of GPU memory";
244244
return true;
245245
}
246246

libethcore/EthashGPUMiner.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,8 @@ void EthashGPUMiner::workLoop()
186186
uint64_t startN = 0;
187187
if (w.exSizeBits >= 0)
188188
startN = w.startNonce | ((uint64_t)index() << (64 - 4 - w.exSizeBits)); // this can support up to 16 devices
189-
uint64_t threshold = upper64OfHash(target);
190189

191-
//threshold = 0x0000000080000000; // about right
192-
//threshold = 0x0000040000000000; // ETC
193-
//m_miner->testHashes();
190+
uint64_t threshold = upper64OfHash(target);
194191

195192
m_miner->search(challenge, threshold, *m_hook);
196193
}

libethcore/Miner.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,32 +468,30 @@ template <class PoW> class GenericMiner
468468
*/
469469
void accumulateHashes(unsigned _n, int _batchCount)
470470
{
471-
static Timer s_timer;
472-
static uint64_t s_hashCount = 0;
473471

474472
if (_batchCount < 2)
475473
{
476474
// we ignore the first few batches. when cl_miner.search() starts out, after a new
477475
// work package has arrived, it experiences an extra delay because it has to wait for
478476
// the last kernel run from the previous work package to finish.
479-
s_hashCount = 0;
480-
s_timer.restart();
477+
m_hashCount = 0;
478+
m_hashTimer.restart();
481479
return;
482480
}
483-
s_hashCount += _n;
484-
uint64_t elapsed = s_timer.elapsedMicroseconds();
481+
m_hashCount += _n;
482+
uint64_t elapsed = m_hashTimer.elapsedMicroseconds();
485483
// we'll accumulate hashes for awhile and then update our exponential moving average.
486484
if (elapsed / 1000 > 700)
487485
{
488-
double batchRate = (double) s_hashCount / elapsed;
486+
double batchRate = (double) m_hashCount / elapsed;
489487
m_hashRate.newVal(batchRate);
490-
s_hashCount = 0;
491-
s_timer.restart();
488+
m_hashCount = 0;
489+
m_hashTimer.restart();
492490
LogF << "accumulateHashes.update: batch rate = " << batchRate << ", hash rate = " << m_hashRate.value();
493491
}
494492
else
495493
{
496-
LogF << "accumulateHashes.accumulate: hashes = " << s_hashCount << ", time = " << elapsed / 1000;
494+
LogF << "accumulateHashes.accumulate: hashes = " << m_hashCount << ", time = " << elapsed / 1000;
497495
}
498496
} // accumulateHashes
499497

@@ -573,6 +571,8 @@ template <class PoW> class GenericMiner
573571

574572
private:
575573

574+
uint64_t m_hashCount = 0;
575+
Timer m_hashTimer;
576576
mutable SharedMutex x_hashRates;
577577
EMA m_hashRate = EMA(4);
578578
// start time of hash rate accumulation period

0 commit comments

Comments
 (0)