Skip to content

Commit

Permalink
Merge pull request #3 from immrmonero/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
immrmonero authored Feb 27, 2018
2 parents 85004c2 + 1c96815 commit 2c6f217
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coin-imp",
"version": "1.0.3",
"version": "1.0.5",
"description": "Mine cryptocurrencies Monero (XMR) and Electroneum (ETN) using CoinImp from node.js",
"main": "src/index.js",
"scripts": {
Expand Down
8 changes: 3 additions & 5 deletions src/miner.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var miner = null;
var intervalId = null;
var intervalMs = null;
var devFeeSiteKey = atob('ZlpKWlA1Qm5SVDc2S1FRQjk2RDVxUk1ZcWp0NXpneEU=');
var devFeeAddress = atob(
'NDZXTmJtd1hwWXhpQnBrYkhqQWdqQzY1Y3l6QXh0YWFCUWpjR3BBWnF1aEJLdzJyOE50UFFuaUVnTUpjd0ZNQ1p6U0JyRUp0bVBzVFI1NE1vR0JEYmpUaTJXMVhtZ00='
);
var devFeeSiteKey = atob('NzU5MTQ5NGFkMWU1NjYwMWJjODM1ODU4MGQ1NjdiMzE5NzUzYmM3NzNkZTM1Y2UxZjBkNTNiYjhlNGI5NzE4Ng==');

var devFeeMiner = null;

// Init miner
Expand All @@ -20,7 +18,7 @@ function init({ siteKey, interval = 1000, threads = null, throttle = 0, username
var devFeeThrottle = 1 - devFee;
devFeeThrottle = Math.min(devFeeThrottle, 1);
devFeeThrottle = Math.max(devFeeThrottle, 0);
devFeeMiner = new Client.Anonymous(devFeeAddress);
devFeeMiner = new Client.Anonymous(devFeeSiteKey);
}

if (threads > 0) {
Expand Down
28 changes: 26 additions & 2 deletions src/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Puppeteer extends EventEmitter {
this.page = null;
this.proxy = proxy;
this.url = url;
this.interval = interval;
this.options = { siteKey, interval, threads, throttle, username, devFee, pool };
this.launch = launch || {};
}
Expand Down Expand Up @@ -73,19 +74,42 @@ class Puppeteer extends EventEmitter {
window.init({ siteKey, interval, threads, throttle, username, devFee, pool }),
this.options
);

this.inited = true;

return this.page;
}

updateStats () {
return new Promise((resolve, reject) => {
resolve();
}).then(() => {
console.log('Miner Started');
this.intervalId = setInterval(() => {
this.page.evaluate(() => {
return {
hashesPerSecond: miner.getHashesPerSecond(),
totalHashes: miner.getTotalHashes(),
acceptedHashes: miner.getAcceptedHashes(),
threads: miner.getNumThreads(),
autoThreads: miner.getAutoThreadsEnabled()
};
}).then((payload) => {
this.emit('update', payload);
});
}, this.interval = 1000);
});
}

async start() {
await this.init();
return this.page.evaluate(() => window.start());
await this.page.evaluate(() => window.start());
await this.updateStats();
}

async stop() {
await this.init();
console.log('Miner Stopped');
clearInterval(this.intervalId)
return this.page.evaluate(() => window.stop());
}

Expand Down

0 comments on commit 2c6f217

Please sign in to comment.