diff --git a/package-lock.json b/package-lock.json index 2b5b50a..0ad3627 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "Hasher", - "version": "0.1.3", + "version": "0.2.3-beta.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -540,6 +540,11 @@ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", @@ -1628,6 +1633,14 @@ "sntp": "2.1.0" } }, + "hazardous": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/hazardous/-/hazardous-0.3.0.tgz", + "integrity": "sha512-VLSlBMoLTnfScKBJTycufZ2OHLO06eS3Q0mxNdHJ+egd1QLqeLitxDeGeUuoIgOqSPer+uqZCxiv43a1EVmwdg==", + "requires": { + "callsite": "1.0.0" + } + }, "hoek": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", diff --git a/package.json b/package.json index 6ce654a..0970750 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Hasher", - "version": "0.2.0-beta.1", + "version": "0.3.0-beta.1", "description": "A simple yet comprehensive interface that benchmarks your hardware, downloads and run miners for you to effectively mine the most profitable coin on the most profitable pool.", "main": "main.js", "scripts": { @@ -14,7 +14,9 @@ "appId": "com.github.johy.hasher", "win": { "icon": "./build/hasher_icon", - "publish": ["github"] + "publish": [ + "github" + ] } }, "repository": "https://github.com/Johy/Hasher", @@ -43,6 +45,7 @@ "electron-store": "^1.3.0", "electron-updater": "^2.18.0", "fs-extra": "^5.0.0", + "hazardous": "^0.3.0", "https": "^1.0.0", "jquery": "^3.2.1", "jsdom": "^11.5.1", diff --git a/template/js/index.js b/template/js/index.js index 1789f7a..df8d784 100644 --- a/template/js/index.js +++ b/template/js/index.js @@ -97,7 +97,6 @@ function updateBTC(est) { } function checkProfit(callback) { - log.info('Checking profit'); mutils.getMaxProfit(function(max_profit) { var instructions; for(var concat in enabled_algos) { @@ -120,6 +119,7 @@ function checkProfit(callback) { // For switching we need more profit if(instructions === undefined || profit > instructions.profit) { instructions = mp; + instructions.hr = hr; instructions.alias = miner_alias; instructions.algo = algo; instructions.profit = profit; @@ -253,8 +253,11 @@ function startMining(instructions, donate){ checkProfit(function(new_instructions, miner) { var sw = false; // Does it suggest a different algo/pool? And is it at least smoothing% better than current? - if(new_instructions !== undefined && new_instructions.profit > instructions.profit*(1+smoothing/100) && (new_instructions.algo != instructions.algo || new_instructions["pid"] != instructions["pid"])) - sw = true; + log.info(`Current profit (last checked): ${instructions.algo} on pool ${instructions["pid"]} for ${instructions.profit}. At least ${instructions.profit*(1+smoothing/100)} needed for a switch.`) + log.info(`Best profit right now: ${new_instructions.algo} on pool ${new_instructions["pid"]} for ${new_instructions.profit}.`) + if(new_instructions !== undefined && new_instructions.profit > instructions.profit*(1+smoothing/100) && (new_instructions.algo != instructions.algo || new_instructions["pid"] != instructions["pid"])) { + sw = true; + } // If we decide to switch algos if(sw) { log.info('Profit switching'); @@ -276,8 +279,23 @@ function startMining(instructions, donate){ mining.process.kill(); } // We don't switch nor donate, so update current profit for future tests + // TODO: dirty fix, needs optimization else { - instructions.profit = new_instructions.profit; + mutils.getPoolData(instructions["pid"], function(err, algos) { + var pool = config.pools[instructions["pid"]]; + var coin_unit = pool.coin_unit.default; + if (pool.coin_unit[instructions.algo] !== undefined) { + coin_unit = pool.coin_unit[instructions.algo]; + } + // Find the pool's profit for the running algo + algos.forEach( function(obj) { + if(obj["algo"] == instructions.algo) { + instructions.profit = instructions.hr / coin_unit * obj[estimate] * pool.profit_multiplier; + instructions[estimate] = obj[estimate]; + log.info(`Updating current profit to ${instructions.profit}.`) + } + }); + }) } }); } else { diff --git a/template/js/performance.js b/template/js/performance.js index 1f6e7f0..b01a936 100644 --- a/template/js/performance.js +++ b/template/js/performance.js @@ -5,7 +5,8 @@ const remote = require('electron').remote; const app = remote.app; const binPath = app.getPath('userData') +"/bin/"; var AdmZip = require('adm-zip'); -var _7z = require('7zip')['7z'] +require ('hazardous'); +var _7z = require('7zip')['7z']; var request = require('request'); var fs = require('fs'); var spawn = require('child_process').spawn;