Skip to content

Commit

Permalink
Fixed an annoying bug with asar preventing to uncompress files
Browse files Browse the repository at this point in the history
  • Loading branch information
fiorinin committed Jan 22, 2018
1 parent 9aff27b commit 172816c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -14,7 +14,9 @@
"appId": "com.github.johy.hasher",
"win": {
"icon": "./build/hasher_icon",
"publish": ["github"]
"publish": [
"github"
]
}
},
"repository": "https://github.com/Johy/Hasher",
Expand Down Expand Up @@ -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",
Expand Down
26 changes: 22 additions & 4 deletions template/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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');
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion template/js/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 172816c

Please sign in to comment.