Skip to content

Commit

Permalink
only use average hashrate for the last loginterval, closes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
selaux committed Mar 23, 2014
1 parent c92dff5 commit 0299012
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/modules/miners/bfgminer.js
Expand Up @@ -127,14 +127,18 @@ module.exports = Module.extend({
calculatedHardwareErrorRate,
returnedHardwareErrorRate,
hardwareErrorRate,
avgHashrateKey,
avgHashrate,
totalDifficulty;

if (response.SUMMARY && response.SUMMARY.length > 0) {
calculatedHardwareErrorRate = (response.SUMMARY[0]['Hardware Errors'] / response.SUMMARY[0].Accepted) * 100;
returnedHardwareErrorRate = response.SUMMARY[0]['Device Hardware%'];
hardwareErrorRate = returnedHardwareErrorRate !== undefined ? returnedHardwareErrorRate : calculatedHardwareErrorRate;
avgHashrate = response.SUMMARY[0]['GHS av'] ? response.SUMMARY[0]['GHS av'] * 1000 : response.SUMMARY[0]['MHS av'];
avgHashrateKey = _.find(_.keys(response.SUMMARY[0]), function (key) {
return key.match(/^MHS\s[0-9]+s$/g) || key.match(/^GHS\s[0-9]+s$/g);
});
avgHashrate = avgHashrateKey.indexOf('GHS') === 0 ? response.SUMMARY[0][avgHashrateKey] * 1000 : response.SUMMARY[0][avgHashrateKey];
totalDifficulty = response.SUMMARY[0]['Difficulty Accepted'] + response.SUMMARY[0]['Difficulty Rejected'] + response.SUMMARY[0]['Difficulty Stale'];

data = _.extend({}, defaults, {
Expand Down
5 changes: 2 additions & 3 deletions test/specs/lib/modules/miners/bfgminerSpec.js
Expand Up @@ -279,7 +279,7 @@ describe('modules/miners/bfgminer', function () {
'Getworks': 9,
'Hardware Errors': 10,
'Local Work': 11,
'MHS av': 12.000,
'MHS 10s': 12.000,
'Network Blocks': 13,
'Rejected': 14,
'Remote Failures': 15,
Expand Down Expand Up @@ -332,8 +332,7 @@ describe('modules/miners/bfgminer', function () {
response,
bfgAdapter = new BfgAdapter({}, config);

summary = _.extend({}, summaryResponse.SUMMARY[0], { 'GHS av': 58 });
delete summary['MHS av'];
summary = _.extend({}, _.omit(summaryResponse.SUMMARY[0], 'MHS 10s'), { 'GHS 10s': 58 });
response = _.extend({}, summaryResponse, { SUMMARY: [ summary ] });

expect(bfgAdapter.handleSummaryResponse(response)).to.deep.equal(_.extend({}, parsedResponse, {
Expand Down

0 comments on commit 0299012

Please sign in to comment.