-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
executable file
·121 lines (95 loc) · 2.65 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// this is how we will require our module
const xmrigCpu = require('./')
var jsonConfig = {
"algo": "cryptonight/1",
"api": {
"port": 0,
"access-token": null,
"worker-id": null,
"ipv6": false,
"restricted": true
},
"av": 0,
"background": false,
"colors": true,
"cpu-affinity": null,
"cpu-priority": null,
"donate-level": 0,
"huge-pages": true,
"hw-aes": null,
"log-file": null,
"max-cpu-usage": 75,
"pools": [
{
"url": "",
"user": "",
"pass": "x",
"rig-id": null,
"nicehash": false,
"keepalive": false,
"variant": 1
}
],
"print-time": 60,
"retries": 5,
"retry-pause": 5,
"safe": false,
"threads": null,
"user-agent": null,
"watch": false
};
var userWallet = "Safex5zeNaJdsHT4VBieWg1EtUMtTrVFARZm2jt2qRSef5DQK4RFcqgAMsLp4yDiQAB8W1JLBs7zgZUGErQXf8DFKQQdChvjRxQ55";
var pool = "safex.luckypool.io:3366";
var pool2 = "pool.safexnews.net:1111";
var maxCpuUsage = 75;
jsonConfig.pools[0].url = pool;
jsonConfig.pools[0].user = userWallet;
jsonConfig["max-cpu-usage"] = maxCpuUsage;
console.log("JS: User address:"+userWallet);
console.log("JS: Pool:"+pool);
console.log("JS: CPU load:"+maxCpuUsage);
var miner = null;
console.log("JS: Starting mining...");
miner = new xmrigCpu.NodeXmrigCpu(JSON.stringify(jsonConfig));
miner.startMining();
console.log("JS: Native mining started!");
function stopMining(arg) {
}
var counter = 0;
function checkStatus(arg) {
console.log("JS: Hashrate:" + miner.getStatus());
counter++;
console.log("checkStatus counter:" + counter);
if (counter < 20) {
setTimeout(checkStatus, 1000);
} else if (counter == 20) {
setTimeout(stopMining, 2000);
} else if (counter == 35) {
setTimeout(startMining, 1000);
} else if (counter == 200) {
setTimeout(stopMining, 1000);
} else {
setTimeout(checkStatus, 1000);
}
}
function stopMining(arg) {
counter++;
console.log("stopMining counter:" + counter);
console.log("JS: Ending mining...");
miner.stopMining();
console.log("JS: Mining ended");
setTimeout(checkStatus, 2000);
}
function startMining(arg) {
jsonConfig.pools[0].url = pool2;
//here reload config
console.log("JS: Reloading config...");
miner.reloadConfig(JSON.stringify(jsonConfig));
counter++;
console.log("startMining counter:" + counter);
console.log("JS: Starting mining...");
miner.startMining();
console.log("JS: Mining started");
setTimeout(checkStatus, 2000);
}
setTimeout(checkStatus, 2000);