Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed deprecated node-icns in favor of png2icons #62

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
550 changes: 287 additions & 263 deletions desktop/main.js

Large diffs are not rendered by default.

190 changes: 96 additions & 94 deletions desktop/miner.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,108 @@
const {spawn} = require('child_process');
const {
spawn
} = require('child_process');
const os = require('os');
const path = require('path');
const stripAnsi = require('strip-ansi');
const platform = os.platform();

const binaryDir = path.join(__dirname, 'miner_binaries');
const binaries = {
linux: path.join(binaryDir, 'bailbloc_worker_linux'),
darwin: path.join(binaryDir, 'bailbloc_worker'),
win32: path.join(binaryDir, 'bailbloc_worker.exe')
linux: path.join(binaryDir, 'bailbloc_worker_linux'),
darwin: path.join(binaryDir, 'bailbloc_worker'),
win32: path.join(binaryDir, 'bailbloc_worker.exe')
};

class Miner {
constructor(props) {
this.args = {
'--url': 'mine.xmrpool.net:5555',
'--user':
'442uGwAdS8c3mS46h6b7KMPQiJcdqmLjjbuetpCfSKzcgv4S56ASPdvXdySiMizGTJ56ScZUyugpSeV6hx19QohZTmjuWiM',
'--pass': 'persistentID:[email protected]',
'--keepalive': '',
'--no-color': '',
'--max-cpu-usage': '25',
'--cpu-priority': '0',
'--print-time': '4'
};

if (props) Object.assign(this.args, props);

this.proc = null;
this.speed = 0.0;
this.binary = binaries[platform];
this.mining = false;
}

makeArgs() {
let args = [];
for (let key in this.args) {
let val = this.args[key];
if (val != '') {
args.push(`${key}=${val}`);
} else {
args.push(key);
}
}
// console.log(args.join(' '));
return args;
}

updateArgs(newArgs) {
Object.assign(this.args, newArgs);
}

parseLog(data) {
// parses stdout looking like:
// [2017-10-08 17:34:13] speed 2.5s/60s/15m 58.3 n/a n/a H/s max: 57.8 H/s

if (data.indexOf('speed') === -1) {
return;
}

// remove color codes
data = stripAnsi(data);

let parts = data.split(' ');
let date = parts[0].replace('[', '');
let time = parts[1].replace(']', '');
let speed = parts[4];

this.speed = speed;
// console.log('speed:', speed);
}

start() {
this.proc = spawn(this.binary, this.makeArgs());

this.proc.stdout.on('data', data => {
this.parseLog('' + data);
});

this.proc.on('close', () => {
this.proc = null;
});

this.mining = true;
}

stop() {
if (this.proc) {
this.proc.kill();
}
this.mining = false;
this.speed = 0;
}

restart() {
if (this.proc) {
this.proc.on('close', () => {
this.start();
});
this.stop();
}
}
constructor(props) {
this.args = {
'--url': 'mine.xmrpool.net:5555',
'--user': '442uGwAdS8c3mS46h6b7KMPQiJcdqmLjjbuetpCfSKzcgv4S56ASPdvXdySiMizGTJ56ScZUyugpSeV6hx19QohZTmjuWiM',
'--pass': 'persistentID:[email protected]',
'--keepalive': '',
'--no-color': '',
'--max-cpu-usage': '25',
'--cpu-priority': '0',
'--print-time': '4'
};

if (props) Object.assign(this.args, props);

this.proc = null;
this.speed = 0.0;
this.binary = binaries[platform];
this.mining = false;
}

makeArgs() {
let args = [];
for (let key in this.args) {
let val = this.args[key];
if (val != '') {
args.push(`${key}=${val}`);
} else {
args.push(key);
}
}
// console.log(args.join(' '));
return args;
}

updateArgs(newArgs) {
Object.assign(this.args, newArgs);
}

parseLog(data) {
// parses stdout looking like:
// [2017-10-08 17:34:13] speed 2.5s/60s/15m 58.3 n/a n/a H/s max: 57.8 H/s

if (data.indexOf('speed') === -1) {
return;
}

// remove color codes
data = stripAnsi(data);
console.log(data);

let parts = data.split(' ');
let date = parts[0].replace('[', '');
let time = parts[1].replace(']', '');
let speed = parts[4];

this.speed = speed;
//console.log('speed:', speed);
}

start() {
this.proc = spawn(this.binary, this.makeArgs());

this.proc.stdout.on('data', data => {
this.parseLog('' + data);
});

this.proc.on('close', () => {
this.proc = null;
});

this.mining = true;
}

stop() {
if (this.proc) {
this.proc.kill();
}
this.mining = false;
this.speed = 0;
}

restart() {
if (this.proc) {
this.proc.on('close', () => {
this.start();
});
this.stop();
}
}
}

module.exports = Miner;
module.exports = Miner;
Binary file modified desktop/miner_binaries/bailbloc_worker
Binary file not shown.
Binary file modified desktop/miner_binaries/bailbloc_worker.exe
100644 → 100755
Binary file not shown.
Binary file modified desktop/miner_binaries/bailbloc_worker_linux
Binary file not shown.
Loading